Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HttpPost]
- public IActionResult Login(UserLoggingInBindingModel model)
- {
- if (this.User.IsAuthenticated)
- {
- return this.RedirectToHome();
- }
- if (!this.IsValidModel(model))
- {
- this.BuildErrorView();
- return View();
- }
- User user;
- var passwordHash = PasswordUtilities.GetPasswordHash(model.Password);
- using (this.Context)
- {
- var users = this.Context.Users.AsQueryable();
- user = users
- .AsEnumerable()
- .FirstOrDefault(t => t.Username == model.Username && t.PasswordHash == passwordHash);
- }
- if (user == null)
- {
- this.BuildErrorView();
- return View();
- }
- this.SignIn(user.Username, user.Id);
- return this.RedirectToHome();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement