public override bool ValidateUser(string username, string password) { var repo = new Repository <Participant>(); var participant = repo.Query.SingleOrDefault(p => p.Email == username); if (participant == null) { return(false); } var hasher = new Sha1Hasher(); var hashedPassword = hasher.ComputeHash(password); var isPasswordValid = hashedPassword == participant.Password; return(isPasswordValid); }
public ActionResult Register(AccountRegisterViewModel viewModel) { var doPasswordsMatch = viewModel.Participant.Password == viewModel.PasswordRepeat; if (!doPasswordsMatch) { ModelState.AddModelError("PasswordRepeat", "Passwörter stimmen nicht überein"); } var isValid = ModelState.IsValid; if (isValid) { var hashedPassword = _sha1Hasher.ComputeHash(viewModel.Participant.Password); viewModel.Participant.Password = hashedPassword; _repository.Insert(viewModel.Participant); return(RedirectToAction("Login")); } return(View(viewModel)); }