コード例 #1
0
        public ActionResult Forgotten(string Email)
        {
            var user = _userService.SetResetToken(Email, UserType.Customer);

            if (user != null)
            {
                _notifyService.ResetPassword(user);
            }
            return(RedirectToAction("Sended", new { to = Email }));
        }
コード例 #2
0
 public ActionResult Forgotten(string Email)
 {
     if (Email.IsNotNullAndWhiteSpace())
     {
         var user = _userService.SetResetToken(Email, UserType.Customer);
         if (user != null)
         {
             _notifyService.ResetPassword(user);
         }
         return(RedirectToAction("Sended", new { to = Email, status = (user != null ? 1 : 2) }));
     }
     return(RedirectToAction("Forgotten"));
 }
コード例 #3
0
 public ActionResult Forgotten(ForgottenViewModel model)
 {
     if (ModelState.IsValid)
     {
         var user = _userService.SetResetToken(model.Email, model.UserType);
         if (user != null)
         {
             _notifyService.ResetPassword(user);
         }
         return(RedirectToAction("Sended", "Account", new { to = model.Email, status = (user != null ? 1 : 2) }));
     }
     return(RedirectToAction("Forgotten", "Account"));
 }
コード例 #4
0
        public async Task ResetPassword(ResetPasswordRequest model)
        {
            var existing = await _userClaimService.GetByToken(model.VerificationCode);

            if (existing == null)
            {
                throw new NotFoundException();
            }
            existing.IsClaimed = true;
            if (model.Password != model.RetypePassword)
            {
                throw new ValidationErrorException();
            }
            existing.User.Password          = _encryptionUtil.Encrypt(model.Password);
            existing.User.PasswordChangedAt = DateTime.UtcNow;
            var user = await _userService.Update(existing.User);

            await _userClaimService.Update(existing);

            var updatedUser = _mapper.Map <IUser>(user);
            await _notifyService.ResetPassword(updatedUser);
        }