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()); }
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()); } }