Exemplo n.º 1
0
        public async Task <ActionResult> ChangePassword(string confirmPassword, string newPassword,
                                                        string currentPassword)
        {
            try
            {
                var hashedPassword = UserManagerApp.PasswordHasher.HashPassword(currentPassword);
                var user           = await UserManagerApp.FindByIdAsync(this.User.Identity.GetUserId());

                if (newPassword == confirmPassword)
                {
                    IdentityResult result =
                        await
                        UserManagerApp.ChangePasswordAsync(User.Identity.GetUserId(), currentPassword, newPassword);

                    if (result.Succeeded)
                    {
                        //  Success("Password updated succesfully");
                        return(RedirectToAction("Index", "Home"));
                    }
                }

                //  Danger("Something was wrong");
                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception)
            {
                throw;
            }
        }