Beispiel #1
0
        /// <summary>
        /// Updates the user's profile.
        /// </summary>
        public async Task UpdatePasswordAsync(string id, UserPasswordVM vm)
        {
            await ValidateAsync(vm);

            var user = await FindAsync(id);

            var token = await _userMgr.GeneratePasswordResetTokenAsync(user);

            await _userMgr.ResetPasswordAsync(user, token, vm.Password);
        }
Beispiel #2
0
 public ActionResult ResetPassword(UserPasswordVM user, string userEmail, string hash)
 {
     if (ModelState.IsValid)
     {
         service.ChangePassword(userEmail, user.Password);
         return(RedirectToAction("Index", "Home", new { message = $"{userEmail},{user.Password}" }));
     }
     else
     {
         return(RedirectToAction("PasswordRecovery", "User", new { Password = user.Password, ConfirmPassword = user.ConfirmPassword, userEmail = userEmail, hash = hash }));
     }
 }
Beispiel #3
0
        /// <summary>
        /// Validates the user password.
        /// </summary>
        private Task ValidateAsync(UserPasswordVM vm)
        {
            if (string.IsNullOrEmpty(vm.Password) || string.IsNullOrEmpty(vm.PasswordConfirmation))
            {
                throw new OperationException("Password cannot be empty.");
            }

            if (vm.Password != vm.PasswordConfirmation)
            {
                throw new OperationException("Passwords do not match.");
            }

            return(Task.CompletedTask);
        }
Beispiel #4
0
        public ActionResult PasswordRecovery(UserPasswordVM user, string userEmail, string hash)
        {
            if (service.GetByKey(userEmail) == null || HashService.GenerateUserHash(service.GetByKey(userEmail)) != hash)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ViewBag.Email = userEmail;
                ViewBag.Hash  = hash;
                ViewBag.User  = user;


                return(View());
            }
        }
Beispiel #5
0
 public Task Update(string id, [FromBody] UserPasswordVM vm)
 {
     return(_userMgr.UpdatePasswordAsync(id, vm));
 }