public void ResetPassword(ResetPasswordInput input)
        {
            var user = _userRepository.Get(input.UserId);
            if (string.IsNullOrWhiteSpace(user.PasswordResetCode))
            {
                throw new UserFriendlyException("You can not reset your password. You must first send a reset password link to your email.");
            }

            if (input.PasswordResetCode != user.PasswordResetCode)
            {
                throw new UserFriendlyException("Password reset code is invalid!");
            }

            user.Password = input.Password;
            user.PasswordResetCode = null;
        }
Ejemplo n.º 2
0
        public JsonResult ResetPassword(ResetPasswordInput input)
        {
            var recaptchaHelper = this.GetRecaptchaVerificationHelper();
            if (String.IsNullOrEmpty(recaptchaHelper.Response))
            {
                throw new UserFriendlyException("Captcha answer cannot be empty.");
            }

            var recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();
            if (recaptchaResult != RecaptchaVerificationResult.Success)
            {
                throw new UserFriendlyException("Incorrect captcha answer.");
            }

            _userAppService.ResetPassword(input);

            return Json(new MvcAjaxResponse { TargetUrl = Url.Action("Login") });
        }