public ActionResult Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { var user = this.userService.GetUserByEmail(model.Email); string hashedPassword = SecurityServices.PasswordHash(model.Password); if (hashedPassword == user.Password) { DormIdentity.CurrentUser = user; FormsAuthentication.SetAuthCookie(user.Email, model.RememberMe); FormsAuthentication.SetAuthCookie(user.Email, true); FormsAuthentication.Authenticate(user.Email, hashedPassword); if (DormIdentity.CurrentUser.Role.Id == (int)Core.Roles.Admin) { return(RedirectToAction("Index", "Dorm", new { area = "Admin" })); } } return(Redirect(returnUrl)); } return(View("../Home/Index", model)); }