Beispiel #1
0
        public ActionResult ResetPassword(ResetPassworsModel model)
        {
            var message = "";

            if (ModelState.IsValid)
            {
                using (UserDBEntities data = new UserDBEntities())
                {
                    var user = data.Users.Where(value => value.ResetPassword == model.ResetCode).FirstOrDefault();
                    if (user != null)
                    {
                        user.Password      = Crypto.Hash(model.NewPassword);
                        user.ResetPassword = "";
                        data.Configuration.ValidateOnSaveEnabled = false;
                        data.SaveChanges();
                        message = "New Password Updated successfully";
                    }
                }
            }
            else
            {
                message = "Somthing Invalide";
            }
            ViewBag.Message = message;
            return(View(model));
        }
Beispiel #2
0
 public ActionResult ResetPassword(string id)
 {
     using (UserDBEntities data = new UserDBEntities())
     {
         var user = data.Users.Where(value => value.ResetPassword == id).FirstOrDefault();
         if (user != null)
         {
             ResetPassworsModel model = new ResetPassworsModel();
             model.ResetCode = id;
             return(View(model));
         }
         else
         {
             return(HttpNotFound());
         }
     }
 }