예제 #1
0
        public ActionResult EnterNewPassword(EnterNewPasswordForm model)
        {
            var api = GoPlayApi.Instance;
            var Verifytoken = api.GetValidVerificationTokenByCode(model.code);
            if (Verifytoken.HasData
                && Verifytoken.Data.is_valid
                && Verifytoken.Data.validation_time >= DateTime.UtcNow)
            {
                if (!ModelState.IsValid)
                {
                    ViewBag.Errors = ModelState.Values.SelectMany(m => m.Errors).First().ErrorMessage;
                    return View(model);
                }

                var user = api.GetUserById(Verifytoken.Data.customer_account_id).Data;
                if (user != null)
                {
                    api.SetPassword(user, model.password);
                    this.Flash(Resources.Resources.Password_changed_successfully, FlashLevel.Success);
                    return RedirectToAction("profile", "account");
                }
            }
            this.Flash(Resources.Resources.Verification_code_is_invalid_or_expired, FlashLevel.Warning);
            return RedirectToAction("reset-password", "account");
        }
예제 #2
0
 public ActionResult EnterNewPassword(string code)
 {
     var Verifytoken = GoPlayApi.Instance.GetValidVerificationTokenByCode(code);
     if (Verifytoken.HasData)
     {
         EnterNewPasswordForm model = new EnterNewPasswordForm();
         model.code = code;
         return View(model);
     }
     else
     {
         return RedirectToAction("reset-password", "account");
     }
 }