コード例 #1
0
        public ActionResult ResetPassword(string token)
        {
            if (string.IsNullOrEmpty(token))
                throw new HttpException((int)HttpStatusCode.NotFound, "not found");

            ResetPasswordRequest request = _membershipService.GetActivePasswordResetRequestByToken(token);

            if (request == null)
                throw new HttpException((int)HttpStatusCode.NotFound, "not found");

            ResetPasswordModel model = new ResetPasswordModel();
            model.Init(_membershipService.MinPasswordLength);
            model.Token = request.Token;

            return View(model);
        }
コード例 #2
0
 public ActionResult ResetPassword(ResetPasswordModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _membershipService.ChangePassword(model.Token, model.NewPassword);
             ViewData.AddRequestSuccessMessage(SuccessMessagesResources.PasswordChangedInfo);
             return View();
         }
         catch (InvalidPasswordTokenException ex)
         {
             throw new HttpException((int)HttpStatusCode.NotFound, "not found", ex);
         }
         catch (InvalidPasswordException)
         {
             ModelState.AddModelError("NewPassword", ValidationResources.RegInvalidPassword);
         }
         catch (UserNotExistsException)
         {
             ModelState.AddModelError("profile", ValidationResources.AccountNotFound);
             return View();
         }
         catch (StaleUserException)
         {
             ModelState.AddModelError("profile", ValidationResources.AccountStalled);
             return View();
         }
     }
     return View(model);
 }