public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { var user = await userRepository.EntityFindByAsync(u => u.Login == model.Login); if (user != null) { if (passwordManager.AreEqual(model.Password, user.Password, user.Salt)) { CreateCookie(user); return(RedirectToAction("Index", "Home")); } } return(Login("Nieprawidłowy login lub hasło")); }
private async Task <ActionResult> AuthorizeUser(LoginViewModel model) { string email = model.Email.ToLower(); var user = await _context.Users.Where(x => x.Email == email).AsNoTracking().FirstOrDefaultAsync(); if (user != null) { if (_passwordManager.AreEqual(model.Password, user.Password, user.Salt)) { CreateCookie(user); return(RedirectToAction("Index", "Dashboard")); } } model.ShowMessage(ToastrType.Error, "Błąd", "Nieprawidłowy login lub hasło."); model.Password = string.Empty; return(View(model)); }