示例#1
0
        public JsonResult ForgotPassword(ForgotPasswordInputModel model)
        {
            try
            {
                Assert.ArgumentNotNull(model, "model");
                ForgotPasswordBaseJsonResult result = new ForgotPasswordBaseJsonResult();

                this.ValidateModel(result);
                if (result.HasErrors)
                {
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }

                var resetResponse = this.AccountManager.ResetUserPassword(this.CurrentStorefront, model);
                if (!resetResponse.ServiceProviderResult.Success)
                {
                    return(Json(new ForgotPasswordBaseJsonResult(resetResponse.ServiceProviderResult)));
                }

                result.Initialize(model.Email);
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                CommerceLog.Current.Error("ForgotPassword", this, e);
                return(Json(new BaseJsonResult("ForgotPassword", e), JsonRequestBehavior.AllowGet));
            }
        }
        public JsonResult ForgotPassword(ForgotPasswordInputModel model)
        {
            try
            {
                Assert.ArgumentNotNull(model, "model");
                ForgotPasswordBaseJsonResult result = new ForgotPasswordBaseJsonResult();
                this.ValidateModel(result);

                if (result.HasErrors)
                {
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }

                var resetResponse = _accountRepository.ResetPassword(model);

                if (!resetResponse.ServiceProviderResult.Success)
                {
                    return(Json(new ForgotPasswordBaseJsonResult(resetResponse.ServiceProviderResult)));
                }

                result.Initialize(model.Email);

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                _logger.LogError("ForgotPassword", this, e);

                return(Json(new BaseJsonResult("ForgotPassword", e), JsonRequestBehavior.AllowGet));
            }
        }