public ActionResult ConfirmAccount(AdminsConfirmAccountVM model) { if (ModelState.IsValid) { Administrator admin = unitOfWork.AdminRepository.GetById(model.Id); admin.Username = model.Username; if (admin != null) { if (PasswordHasher.Equals(model.Password, admin.Salt, admin.Hash)) { var passPhrase = PasswordHasher.Hash(model.NewPassword); admin.Hash = passPhrase.Hash; admin.Salt = passPhrase.Salt; admin.IsConfirmed = true; unitOfWork.AdminRepository.Update(admin); unitOfWork.Save(); TempData.FlashMessage("Your account has been confirmed. Please, login!"); return(RedirectToAction("Login", "Account")); } else { ModelState.AddModelError("", "Incorrect Password"); } } } return(View(model)); }
public ActionResult ConfirmAccount(int?id) { if (AuthenticationManager.LoggedUser != null) { TempData.FlashMessage("You are logged in! Please log out and then verify!", null, FlashMessageTypeEnum.Red); return(RedirectToAction("Index", "Home")); } if (!id.HasValue) { return(RedirectToAction("NotFound", "Error")); } Administrator admin = unitOfWork.AdminRepository.GetById(id.Value); if (admin == null || admin.IsConfirmed) { return(RedirectToAction("NotFound", "Error")); } AdminsConfirmAccountVM model = new AdminsConfirmAccountVM(); model.Id = id.Value; return(View(model)); }