Ejemplo n.º 1
0
        public async Task <ActionResult> ResetPasswordPartial(UserAccountResetPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_ResetPasswordPartial", model));
            }

            // Get user details
            var user = await _userManager.FindByIdAsync(model.UserId);

            // Check if user exist
            if (user == null)
            {
                return(PartialView("_FailureToLoadDataPartial"));
            }

            // Generate password reset token
            string resetToken = await _userManager.GeneratePasswordResetTokenAsync(user);

            // Reset the user account password
            var result = await _userManager.ResetPasswordAsync(user, resetToken, model.Password);

            // Check if password is successful
            if (result.Succeeded)
            {
                // Return and notify success
                return(PartialView("_SuccessUpdatePartial"));
            }

            AddErrors(result);

            // Return the reset password form view with error
            return(PartialView("_ResetPasswordPartial", model));
        }
Ejemplo n.º 2
0
        public ActionResult ResetPasswordPartial(string id, string username)
        {
            // Initialize user account reset password view model
            var model = new UserAccountResetPasswordViewModel
            {
                UserId   = id,
                Username = username
            };

            // Return the reset password form view
            return(PartialView("_ResetPasswordPartial", model));
        }