예제 #1
0
        public virtual ActionResult ResetPasswordCallback(ResetPasswordCallbackModel model, string returnUrl)
        {
            if (model == null)
            {
                throw new HttpException((int)HttpStatusCode.NotFound, Resources.Error_NotFound_Customer);
            }

            if (!ModelState.IsValid)
            {
                return(ViewAsync(Views.ResetPasswordCallback, Views._ResetPasswordCallback, model));
            }

            var dbCustomer = _customerRepository.GetByResetPasswordToken(model.ResetPasswordToken);

            if (dbCustomer == null)
            {
                throw new HttpException((int)HttpStatusCode.NotFound, Resources.Error_NotFound_Customer);
            }

            if (dbCustomer.ResetPasswordExpiresDateUtc < DateTime.Now)
            {
                return(RedirectedAsync(returnUrl, Resources.Validation_ResetPasswordExpired, true));
            }

            SecurityHelpers.UpdateCustomerPassword(dbCustomer, model.NewPassword, true);

            _customerRepository.AddOrUpdate(dbCustomer);
            _customerRepository.SaveChanges();

            _notificationController.PasswordReset(dbCustomer);

            return(RedirectedAsync(returnUrl, Resources.Success_ResetPasswordTokenSent));
        }
예제 #2
0
        public virtual ActionResult ResetPasswordCallback(string resetPasswordToken, string returnUrl)
        {
            var dbCustomer = _customerRepository.GetByResetPasswordToken(resetPasswordToken);

            if (dbCustomer == null)
            {
                throw new HttpException((int)HttpStatusCode.NotFound, Resources.Error_NotFound_Customer);
            }

            var model = new ResetPasswordCallbackModel {
                ResetPasswordToken = dbCustomer.ResetPasswordToken
            };

            if (dbCustomer.ResetPasswordExpiresDateUtc < DateTime.Now)
            {
                return(RedirectedAsync(returnUrl, Resources.Validation_ResetPasswordExpired, true));
            }

            return(ViewAsync(Views.ResetPasswordCallback, Views._ResetPasswordCallback, model));
        }