Exemplo n.º 1
0
 // GET: /Account/ResetPassword
 public ActionResult ResetPassword(string prc)
 {
     if (AccountService.IsValidResetUrl(prc))
         {
             ResetPasswordModel model = new ResetPasswordModel();
             return View(model);
         }
         else
         {
             return RedirectToAction("InvalidUrl", "Content");
         }
 }
Exemplo n.º 2
0
 public ActionResult ResetPassword(ResetPasswordModel model)
 {
     //validate model, set new password
         if (ModelState.IsValid)
         {
             try
             {
                 model.Code = Request.Params["prc"];
                 AccountService.ResetPassword(model);
                 return RedirectToAction("Index", "Home", new { });
             }
             catch (ReturnEmailNotFoundException ex)
             {
                 return RedirectToAction("InvalidUrl", "Content");
             }
         }
         else
         {
             return View(model);
         }
 }
Exemplo n.º 3
0
        public void ResetPassword(ResetPasswordModel model)
        {
            using (IDocumentSession Session = DataDocumentStore.Instance.OpenSession())
            {
                //Find matching return email document
                var returnEmailDocument = Session.Query<ReturnEmailDocument>().Where(x => x.Hash == System.Uri.UnescapeDataString(model.Code)).Where(x => x.Timestamp <= System.DateTime.Now.AddDays(1)).SingleOrDefault();

                if (returnEmailDocument != null)
                {
                    //Get user based on id
                    var user = Session.Load<AccountUserDocument>(returnEmailDocument.UserId);

                    //Set the flag
                    user.SetPassword(model.Password);

                    //Delete the returnEmailDocument
                    Session.Advanced.DocumentStore.DatabaseCommands.Delete(returnEmailDocument.Id, null);

                    Session.SaveChanges();

                }
                else
                {
                    throw new ReturnEmailNotFoundException();
                }

            }
        }