public ActionResult Login(LoginModel model) { if (ModelState.IsValid) { IdentityUser user = this._userManager.Find(model.Username, model.Password); if (user != null) { ClaimsIdentity userClaimsIdentity = this._userManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); var authManager = Request.GetOwinContext().Authentication; authManager.SignIn(userClaimsIdentity); if (this._userManager.IsInRole(user.Id, "Admin")) { return RedirectToRoute("admin.dashboard.index_page"); } return Redirect(GetReturnUrl(model.ReturnUrl)); } } ViewBag.Error = "Username or password does not match"; return View(model); }
public ActionResult Login(string returnUrl) { var model = new LoginModel() { ReturnUrl = returnUrl }; return View(model); }