예제 #1
0
        public ActionResult Login(LoginViewModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                if (_auth.Athenticate(model.UserName, model.Password))
                {
                    return(Redirect(returnUrl ?? Url.Action("Index", "Admin")));
                }
                else
                {
                    ModelState.AddModelError("", "Incorrect username or password");
                    return(View());
                }
            }

            return(View());
        }
예제 #2
0
 public ActionResult Login(LoginViewModel model, string returnUrl)
 {
     if (ModelState.IsValid)
     {
         // try authentify
         // if ok redirect to admin/index
         if (_authProvider.Athenticate(model.UserName, model.Password))
         {
             return(Redirect(returnUrl ?? Url.Action("Index", "Admin")));
         }
         else
         {
             // this message will be added to validation errors dictionnary
             ModelState.AddModelError("", "Incorrect username or password");
             return(View());
         }
     }
     else
     {
         return(View());
     }
 }