Ejemplo n.º 1
0
        public async Task<ActionResult> EnterNewPassword(EnterNewPasswordForm model)
        {
            var api = Platform.Core.Api.Instance;
            var Verifytoken = Platform.Core.Api.Instance.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.GetUserByUserName(Verifytoken.Data.customer_username).Data;
                if (user != null)
                {
                    api.SetPassword(user, model.password);
                    //return RedirectToAction("", model.next);

                    //Login User
                    var applicationUser = new ApplicationUser()
                    {
                        Id = user.id,
                        Email = user.email,
                        UserName = user.username
                    };

                    await SignInAsync(applicationUser, false);

                    if (!string.IsNullOrEmpty(model.next))
                        return Redirect(model.next);

                    return Json(new { success = true, redirect = Url.Action("index", "transaction") });
                }
            }

            return RedirectToAction("reset-password", "account");
        }
Ejemplo n.º 2
0
        public ActionResult EnterNewPassword(string code, string next)
        {

            var Verifytoken = Platform.Core.Api.Instance.GetValidVerificationTokenByCode(code);
            if (Verifytoken.HasData)
            {
                EnterNewPasswordForm model = new EnterNewPasswordForm();
                model.next = next;
                model.code = code;
                //model.is_valid = Verifytoken.Data.is_valid;
                //model.validation_time = Verifytoken.Data.validation_time;
                //model.username = Verifytoken.Data.customer_username;
                return View(model);
            }
            else
            {
                return RedirectToAction("reset-password", "account");
            }
        }