public ActionResult Login(string redirectUrl) { if (AuthenticationService.LoggedUser != null) { return RedirectToAction("Index", "Home"); } AccountLoginVM model = new AccountLoginVM(); if (!String.IsNullOrEmpty(redirectUrl)) { model.RedirectUrl = redirectUrl; } return View(model); }
public ActionResult Login() { AccountLoginVM model = new AccountLoginVM(); TryUpdateModel(model); AuthenticationService.AuthenticateUser(model.Username, model.Password); if (AuthenticationService.LoggedUser == null) { ModelState.AddModelError(String.Empty, "Invalid username or password"); return View(model); } if (String.IsNullOrEmpty(model.RedirectUrl)) { return RedirectToAction("Index", "Home"); } return Redirect(model.RedirectUrl); }