public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid) { if (Membership.ValidateUser(model.UserName, model.Password)) { return GrantedAccess(model); } } // If we got this far, something failed, redisplay form ModelState.AddModelError("", Global.Login_LoginFailed); return View(model); }
private ActionResult GrantedAccess(LoginModel model) { try { MembershipUser authenticatedUser = Membership.GetUser(model.UserName); if (authenticatedUser == null) { throw new GenericException(Global.Login_LoginFailed); } ApplicationUserDto applicationUser = SecurityService.GetUserAccountInformation(Guid.Parse(authenticatedUser.ProviderUserKey.ToString())); applicationUser.Email = authenticatedUser.UserName; return CookiesAndContextAssignation(applicationUser); } catch (Exception ex) { ModelState.AddModelError(string.Empty, Global.Login_LoginFailed); Logger.Error(ex.Message); } return View(model); }