コード例 #1
0
        public virtual ActionResult Reset(ResetForgottenPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            //
            //Validate the id and token
            //This will decrypt the values, find the record, and ensure its not expired
            //If not valid then throw error, and redirect to ForgotPassword page to have them enter userid and email
            //
            var request = new ResetForgottenPasswordRequest()
            {
                Id                 = model.Id,
                Token              = model.Token,
                NewPassword        = model.NewPassword,
                NewPasswordConfirm = model.NewPasswordConfirm
            };
            var response = _service.ResetForgottenPassword(request);

            if (!response.IsSuccessful)
            {
                //Redirect to the forgot password page with an error message if there is an issue
                ModelState.AddModelError("", response.Message);
                return(View("Reset", model));
            }
            else
            {
                return(View("PasswordSuccessfullyReset", model));
            }
        }
コード例 #2
0
        public virtual ActionResult Reset(String id, String t)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            //
            //Validate the id and token
            //This will decrypt the values, find the record, and ensure its not expired
            //If not valid then throw error, and redirect to ForgotPassword page to have them enter userid and email
            //
            var request = new ValidateSecurityPasswordResetTokenRequest()
            {
                Id    = id,
                Token = t
            };
            var response = _service.ValidateSecurityPasswordResetToken(request);

            if (!response.IsSuccessful)
            {
                //Redirect to the home page with an error message if there is an issue
                AddToastMessage(new ToastMessage
                {
                    AutoHide = false,
                    Position = ToastMessage.ToastPosition.TopCenter,
                    Type     = ToastMessage.ToastType.Error,
                    Title    = "Invalid Request",
                    Message  = response.Message
                });
                return(RedirectToAction(MVC.Home.Index()));
            }

            //
            //If valid, render the view allowing the password to be reset
            //
            var model = new ResetForgottenPasswordViewModel()
            {
                Id    = id,
                Token = t
            };

            return(View(model));
        }