public async Task <ActionResult> SignIn(Login model, string returnUrl) { if (ModelState.IsValid) { ApplicationUser user = await UserManager.FindAsync(model.UserName, model.Password); if (user == null) { ModelState.AddModelError("", "Wrong username or password"); } //else if(ProfileInfo.IsBlocked(model.UserName)) //check if user is blocked //{ // ModelState.AddModelError("", "Your account is blocked"); //} else { ClaimsIdentity claim = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie); AuthenticationManager.SignOut(); //IsPersistent - to save authentication after browser closing AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = true }, claim); int id = UserManager.FindByName(model.UserName).User.Id; //get current user's id ProfileInfo.CheckLevelInfo(id); //try to change forum level if (!String.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); } return(RedirectToAction("Index", "Home")); } } ViewBag.ReturnUrl = returnUrl; return(View(model)); }