public async Task <ActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var user = BoardSquaresRepository.Context.Users.FirstOrDefault(r => r.Email == model.Email);

            if (user == null)
            {
                // Don't reveal that the user does not exist
                return(RedirectToAction("ResetPasswordConfirmation", "Account"));
            }
            var result = BoardSquaresRepository.AttemptPasswordReset(user.UserID, model.Code, model.Password);

            if (result == 1)
            {
                return(RedirectToAction("ResetPasswordConfirmation", "Account"));
            }
            return(View());
        }
Beispiel #2
0
        public async Task <ActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var user = BoardSquaresRepository.Context.Users.FirstOrDefault(r => r.Email == model.Email);

            if (user == null)
            {
                // Don't reveal that the user does not exist
                return(RedirectToAction("ResetPasswordConfirmation", "Account"));
            }
            var result = BoardSquaresRepository.AttemptPasswordReset(user.UserID, model.Code, model.Password);

            if (result == 1)
            {
                return(RedirectToAction("ResetPasswordConfirmation", "Account"));
            }

            TempData["Error"] = $"Unable to reset your password. Please use the <a href=\"{Url.Action("ForgotPassword", "Account")}\">Forgot Password</a> page to request a new password reset email.";
            return(View());
        }