public ActionResult Login(LoginViewModel loginviewmodel, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                //ToDo : Encrypt the password before sending the password
                string password = CryptUtils.GetPasswordEncrypted(loginviewmodel.Password);
                if (provider.ValidateUser(loginviewmodel.UserName, password))
                {
                    FormsAuth.SignIn(loginviewmodel.UserName, false);
                    return(RedirectToLocal(returnUrl));
                }
                ModelState.AddModelError("", "The user name or password provided is incorrect.");
                ViewBag.ErrorMessage = "The user name or password provided is incorrect.";
            }


            return(View("LoginFlat", loginviewmodel));
        }
Exemple #2
0
 public bool ChangeUserPassword(User user, string oldPassword, string newPassword)
 {
     try
     {
         var    appUser      = this.DbFactory.Users.Find(user.UserId);
         string eoldPassword = CryptUtils.GetPasswordEncrypted(oldPassword);
         if (eoldPassword.Equals(appUser.UserPassword))
         {
             string enewPassword = CryptUtils.GetPasswordEncrypted(newPassword);
             appUser.UserPassword         = enewPassword;
             this.db.Entry(appUser).State = System.Data.Entity.EntityState.Modified;
             this.db.SaveChanges();
             return(true);
         }
     }
     catch { }
     return(false);
 }