public ActionResult Login(LogInModel model) { if (!ModelState.IsValid) { return(View("LogIn")); } var account = authenticationManager.GetAccount(model.Username); var artist = authenticationManager.GetArtistWithAccountId(account.AccountID); if (authenticationManager.CheckAccountValidity(model.Username, model.Password)) { var role = authenticationManager.GetAccount(model.Username).Role.RoleName; var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.NameIdentifier, artist.ArtistID.ToString()), new Claim(ClaimTypes.Name, model.Username), new Claim(ClaimTypes.Role, role.ToString()) }, "ApplicationCookie"); var ctx = Request.GetOwinContext(); var authManager = ctx.Authentication; stats.addUser(); authManager.SignIn(identity); return(RedirectToAction("Index", "Murals")); } ModelState.AddModelError("", "Uw gebruikersnaam of wachtwoord is onjuist of u heeft nog geen toegang tot het systeem."); return(View("LogIn")); }