public async Task<ActionResult> Login(LoginVM model) { if (ModelState.IsValid) { var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, true); if (result == SignInStatus.Success) { return RedirectToReturnUrl("~/Profile"); } else if (result == SignInStatus.LockedOut) { ModelState.AddModelError(string.Empty, "Account has been temporarily locked for too many failed login attempts."); } else if (result == SignInStatus.RequiresVerification) { ModelState.AddModelError(string.Empty, "Account has not been verified."); } else { ModelState.AddModelError(string.Empty, "Login failed, incorrect email and/or password."); } } model.Password = string.Empty; return View(model); }
public ActionResult Login(LoginVM login) { if (ModelState.IsValid) { _authFacade.GetToken(login.Username, login.Password); Customer c = _customerFacade.Get(); Session[Global.RolesSessionVar] = GenericFacade.Roles; Session[Global.UsernameSessionVar] = login.Username; if (c != null || !GenericFacade.Roles.Contains(Global.AdminRole)) { Session[Global.UserIdSessionVar] = c.Id; } string url = (string)Session["PrevUrl"]; return(Redirect(url)); } return(View(login)); }
public void Login(LoginVM userToLogin, string sessionId) { if (!this.Contex.Sessions.Any(login => login.SessionId == sessionId)) { this.Contex.Sessions.Add(new Session() { SessionId = sessionId }); this.Contex.SaveChanges(); } var user = Contex.Users.FirstOrDefault( x => x.Username == userToLogin.Username && x.Password == userToLogin.Password); if (user != null) { var session = Contex.Sessions.FirstOrDefault(x => x.SessionId == sessionId); session.IsActive = true; session.User = user; Contex.SaveChanges(); } }
public ActionResult Login(LoginVM vm) { var user = vm.DoLogin(); if (user == null) { return(View(vm)); } else { LoginUserInfo = user; string url = ""; if (!string.IsNullOrEmpty(vm.Redirect)) { url = vm.Redirect; } else { url = "/"; } return(Redirect(HttpUtility.UrlDecode(url))); } }
public async Task<IActionResult> Login(LoginVM model) { if (ModelState.IsValid) { var result = await signInManager.PasswordSignInAsync( model.Username, model.Password, model.RememberMe, false); if (result.Succeeded) { if (!string.IsNullOrEmpty(model.ReturnUrl) && Url.IsLocalUrl(model.ReturnUrl)) { return Redirect(model.ReturnUrl); } else { return RedirectToAction("Index", "Home"); } } } ModelState.AddModelError("", "Invalid login attempt"); return View(model); }
public async Task <User> Login(LoginVM loginVM) { Pwi2.WSSoapClient pwi2 = new Pwi2.WSSoapClient(Pwi2.WSSoapClient.EndpointConfiguration.WSSoap12); var belepokod = loginVM.email; var jelszo = loginVM.password; var alkalmazas = _configuration["SiteCode"]; Pwi2.FelhasznaloLoginResponse resp = await pwi2.FelhasznaloLoginAsync(belepokod, jelszo, alkalmazas); if (resp.Body.FelhasznaloLoginResult.ErrorCode == Pwi2.WMWIErrorCode.NoError) { var userResp = resp.Body.FelhasznaloLoginResult.List[0]; var user = new User { FelhasznaloID = userResp.FelhasznaloID, Email = userResp.Email, Nev = userResp.Nev }; return(user); } return(null); }
public ActionResult <object> Login([FromBody] LoginVM model) { LoginVM login = new LoginVM(); sys_user_Entity user = this._repository.GetUserByAccount(model.User_Account); if (user == null || !model.Password.Equals(user.Password)) { return(login.ResponseNotLogin("登录失败")); } user.Password = ""; var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(this._configuration["JWT:SecurityKey"])); var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); var claims = new[] { new Claim(ClaimTypes.Name, user.ToJson()) }; var authTime = DateTime.UtcNow; var expiresAt = authTime.AddDays(7); var token = new JwtSecurityToken(issuer: "*", audience: "*", claims: claims, expires: expiresAt, signingCredentials: creds); login.token = Constant.JwtTokenPrefix + new JwtSecurityTokenHandler().WriteToken(token); //HttpContext.Session.SetString(login.token, user.ToJson()); return(login.ResponseSuccess()); }
public async Task <IActionResult> Login(LoginVM model, string returnUrl) { if (ModelState.IsValid) { var result = await signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure : false); if (result.Succeeded) { if (!string.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); } else { return(RedirectToAction("index", "employee")); } } ModelState.AddModelError("", "Invalied LogIn !"); } return(View(model)); }
public ActionResult Login(LoginVM vm) { if (ModelState.IsValid) { if (vm.Password.Equals("parku")) { FormsAuthentication.RedirectFromLoginPage("user", false); return(RedirectToAction("Index")); } else if (vm.Password.Equals("guest")) { FormsAuthentication.RedirectFromLoginPage("guest", false); return(RedirectToAction("Index")); } else if (vm.Password.Equals("mrcat")) { FormsAuthentication.RedirectFromLoginPage("admin", false); return(RedirectToAction("Index")); } ModelState.AddModelError("", "Incorrect password"); } return(View(vm)); }
public async Task <IActionResult> Login(LoginVM loginVM) { if (!ModelState.IsValid) { return(View(loginVM)); } SUser appUser = await _userManager.FindByEmailAsync(loginVM.Email); if (appUser == null) { ModelState.AddModelError("", "Email is wrong"); return(View(loginVM)); } Microsoft.AspNetCore.Identity.SignInResult result = await _signManager.PasswordSignInAsync(appUser, loginVM.Password, loginVM.RememberMe, false); if (!result.Succeeded) { ModelState.AddModelError("", "Password is wrong"); return(View(loginVM)); } return(RedirectToAction("Index", "Home")); }
public async Task <string> GetToken(string userName, string password) { LoginVM loginVm = new LoginVM { UserName = userName, Password = password }; //LoginController lc=new LoginController(_config,_appDbContext); //return lc.Login2(loginVm); using (var client = new HttpClient()) { //client.BaseAddress = new Uri("http://localhost:62305/api/"); //HTTP GET var result = await client.PostAsJsonAsync("http://localhost:62305/api/token", loginVm); if (result.IsSuccessStatusCode) { return(await result.Content.ReadAsStringAsync()); } } return(null); }
public async Task <IActionResult> Login(LoginVM model, string returnUrl) { if (ModelState.IsValid) { var result = await signInManager.PasswordSignInAsync( model.Email, model.Password, model.RememberMe, false); if (result.Succeeded) { if (!string.IsNullOrEmpty(returnUrl)) { return(LocalRedirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } } ModelState.AddModelError(string.Empty, "Invalid Login Attempt"); } return(View(model)); }
public async Task <IActionResult> Login(LoginVM loginVM) { if (!ModelState.IsValid) { return(View(loginVM)); } var user = await _userManager.FindByNameAsync(loginVM.UserName); if (user != null) { var result = await _signInManager.PasswordSignInAsync(user, loginVM.Password, false, false); if (result.Succeeded) { return(RedirectToAction("Index", "Home")); } } ModelState.AddModelError("", "Nazwa użytkownika/hasło nie właściwe"); return(View(loginVM)); }
public ActionResult Login(LoginVM model) { if (ModelState.IsValid) { var user = mr.LoginMb(model.Email, model.Password); Session["CurrentUser"] = user.ProccessResult; if (user.ProccessResult != null) { FormsAuthentication.SetAuthCookie(user.ProccessResult.UserID.ToString(), true); if (user.ProccessResult.RoleID == 1) { return(RedirectToAction("List", "Admin/Product")); } else if (user.ProccessResult.RoleID == 2) { return(RedirectToAction("Index", "Home")); } } } ViewBag.Message = "Email or Password Wrong!"; return(View()); }
public IActionResult Put(int id, [FromBody] LoginVM Login) { var loginFound = _loginRepository.GetById(Login.Id); if (loginFound != null) { var encryptedLoginName = Crypto.Encrypt(Login.LoginName, _passPhrase); var encryptedPassword = Crypto.Encrypt(Login.LoginPassword, _passPhrase); // Map updated details to the found Login loginFound.Name = Login.Name; loginFound.LoginName = encryptedLoginName; loginFound.LoginPassword = encryptedPassword; loginFound.WebSiteUrl = Login.WebSiteUrl; loginFound.Notes = Login.Notes; _loginRepository.Update(); return(Ok()); } return(NotFound()); }
public async Task <IActionResult> Login(LoginVM model) { if (ModelState.IsValid) { LoginDBO loginModel = await db.Users.FirstOrDefaultAsync(u => u.Log == model.Log && u.Pass == model.Pass); if (loginModel != null) { await Authenticate(model.Log); // аутентификация return(Redirect("/admin/DashBoard/Products")); } else { TempData["SM"] = "Некорректные логин и(или) пароль"; return(View(model)); } } else { return(View(model)); } }
public async Task <IActionResult> Index(LoginVM model) { if (ModelState.IsValid) { AdminUser adminuser = _vatancontext.AdminUsers.FirstOrDefault(x => x.EMail == model.EMail && x.Password == model.Password); if (adminuser != null) { var claims = new List <Claim> { new Claim(ClaimTypes.Name, model.EMail), new Claim(ClaimTypes.Role, adminuser.Roles) }; var userIdentity = new ClaimsIdentity(claims, "login"); ClaimsPrincipal principal = new ClaimsPrincipal(userIdentity); await HttpContext.SignInAsync(principal); adminuser.Lastlogindate = DateTime.Now; _vatancontext.SaveChanges(); return(RedirectToAction("Index", "Home")); } else { ViewBag.error = "Kullanıcı adı veya şifre hatalı!"; return(View()); } } else { return(View()); } }
public async Task <IActionResult> Login(LoginVM login) { if (!ModelState.IsValid) { return(View()); } AppUser appUser = await _userManager.FindByEmailAsync(login.Email); if (appUser == null) { ModelState.AddModelError("", "Email or Password is wrong!!"); return(View(login)); } if (!appUser.IsActivated) { ModelState.AddModelError("", "Email is Disabled!!"); return(View(login)); } var signinResult = await _signInManager.PasswordSignInAsync(appUser, login.Password, true, true); if (!signinResult.Succeeded) { ModelState.AddModelError("", "Email or Password is wrong!!"); return(View(login)); } if (signinResult.IsLockedOut) { ModelState.AddModelError("", "The account is locked Out"); return(View(login)); } //var role = (await _userManager.GetRolesAsync(appUser))[0]; //if (role == "Admin") //{ // return RedirectToAction("Index", "Dashboard", new { area = "Admin" }); //} return(RedirectToAction("Index", "Home")); }
private void LogOut_Click(object sender, RoutedEventArgs e) { try { var mainVM = (App.Current.MainWindow as MainWindow).DataContext as MainVM; if (mainVM != null) { mainVM.TanVM = null; mainVM.UserName = string.Empty; mainVM.ValidationVM = null; mainVM.EnableEditor = Visibility.Collapsed; mainVM.EnableLanding = Visibility.Visible; mainVM.EnableTaskAllocation = Visibility.Collapsed; mainVM.IsTanLoaded = Visibility.Collapsed; S.CloseAllWindows(); var taskSheetVm = (mainVM.taskSheet?.DataContext as TaskSheetVM); if (taskSheetVm != null) { taskSheetVm.ClearTaskSheet(); } LoginVM loginVM = new LoginVM(); LoginWindow.OpenLoginForm(loginVM); if (!String.IsNullOrEmpty(U.UserName)) { LoginWindow.HideLoginForm(); var check = U.RoleId == (int)Role.ProjectManger || U.RoleId == (int)Role.ToolManager; mainVM.ShowDeliveryTab = mainVM.SettingsVisible = check ? Visibility.Visible : Visibility.Collapsed; mainVM.AssignTaskVisble = check; mainVM.SaveEnabled = U.RoleId == (int)Role.ProjectManger || U.RoleId == (int)Role.ToolManager ? false : true; } } } catch (Exception ex) { Log.This(ex); } }
public IActionResult loginUser(Wrapper loginModel) { if (loginModel.Login.LoginEmail == null && loginModel.Login.LoginPassword == null) { return(View("Index", loginModel)); } LoginVM user = loginModel.Login; User TestUser = _context.Users.SingleOrDefault(u => u.Email == user.LoginEmail); if (TestUser == null) { TempData["LoginError"] = "Username or Password is incorrect"; return(View("Index", loginModel)); } else { if (user.LoginEmail != TestUser.Email) { TempData["LoginError"] = "Username or Password is incorrect"; return(View("Index", loginModel)); } else { var Hasher = new PasswordHasher <User>(); if (0 != Hasher.VerifyHashedPassword(TestUser, TestUser.Password, user.LoginPassword)) { HttpContext.Session.SetInt32("UserId", TestUser.UserId); return(RedirectToAction("DisplayAll", "Weddings")); } else { TempData["LoginError"] = "Username or Password is incorrect"; return(View("Index", loginModel)); } } } }
public async Task <IActionResult> OnPostAsync([FromBody] LoginVM loginVM) { if (ModelState.IsValid) { var result = await _signInManager.PasswordSignInAsync(loginVM.Email.ToUpper(), loginVM.Password, loginVM.RememberMe, lockoutOnFailure : true); if (result.Succeeded) { var UserManager = _serviceProvider .GetRequiredService <UserManager <IdentityUser> >(); var user = await UserManager.FindByEmailAsync(loginVM.Email); if (user != null) { var tokenString = GenerateJSONWebToken(user); var jsonOK = new { tokenString = tokenString, StatusCode = "OK", currentUser = loginVM.Email }; return(new ObjectResult(jsonOK)); } } else if (result.IsLockedOut) { var jsonLocked = new { tokenString = "", StatusCode = "Locked out." }; return(new ObjectResult(jsonLocked)); } } var jsonInvalid = new { tokenString = "", StatusCode = "Invalid Login." }; return(new ObjectResult(jsonInvalid)); }
public async Task <IActionResult> Login(LoginVM login) { if (!ModelState.IsValid) { return(View(login)); } User user = await _userManager.FindByEmailAsync(login.Email); if (user == null) { ModelState.AddModelError(string.Empty, "Email or Password is incorrect!!!"); return(View(login)); } if (user.Deleted == true) { ModelState.AddModelError(string.Empty, "This user has been deleted"); return(View(login)); } Microsoft.AspNetCore.Identity.SignInResult signInResult; if (login.Checked) { signInResult = await _signInManager.PasswordSignInAsync(user, login.Password, true, true); } else { signInResult = await _signInManager.PasswordSignInAsync(user, login.Password, false, true); } if (!signInResult.Succeeded) { ModelState.AddModelError(string.Empty, "Email or Password is incorrect!!!"); return(View(login)); } return(RedirectToAction("Index", "Home")); }
public async Task <IActionResult> Login(LoginVM login) { if (!ModelState.IsValid) { return(View()); } AppUser user = await _userManager.FindByEmailAsync(login.Email); if (user == null) { ModelState.AddModelError("", "Email or password wrong!!!"); return(View()); } if (user.IsDeleted) { ModelState.AddModelError("", "This account blocked!!!"); return(View()); } Microsoft.AspNetCore.Identity.SignInResult signInResult = await _signInManager.PasswordSignInAsync(user, login.Password, true, true); if (signInResult.IsLockedOut) { ModelState.AddModelError("", "Please,try few minutes later"); return(View(login)); } if (!signInResult.Succeeded) { ModelState.AddModelError("", "Email or password wrong!!!"); return(View()); } return(RedirectToAction("Index", "Home")); }
public ActionResult Login(LoginVM credentials) { if (ModelState.IsValid) { if (service.AppUserService.CheckCredentials(credentials.UserName, credentials.Password)) { AppUser user = service.AppUserService.FindByUserName(credentials.UserName); string cookie = user.UserName; FormsAuthentication.SetAuthCookie(cookie, true); if (user.Role == DAL.ORM.Enum.Role.Admin) { Session["FullName"] = user.FirstName + " " + user.LastName; return(Redirect("/Admin/Home/Index")); } else if (user.Role == DAL.ORM.Enum.Role.Author) { Session["ID"] = user.ID; Session["FullName"] = user.FirstName + " " + user.LastName; return(Redirect("/Author/AuthorHome/Index")); } else if (user.Role == DAL.ORM.Enum.Role.Member) { Session["FullName"] = user.FirstName + " " + user.LastName; return(Redirect("/Member/MemberHome/Index")); } } else { ViewData["error"] = "Kullanıcı Adı veya Şifre Hatalı"; return(View()); } } TempData["class"] = "custom-show"; return(View()); }
public ActionResult Login(LoginVM credentials) { if (userService.CheckCredentials(credentials.UserName, credentials.Password)) { User user = userService.FindByUserName(credentials.UserName); if (user.IsAdmin) { if (user.Status == Data.ORM.Enum.Status.Deleted) { return(View()); } else { Session["name"] = user.UserName; Session["ID"] = user.ID; string cookie = user.UserName; FormsAuthentication.SetAuthCookie(cookie, true); return(Redirect("/SysAdmin/Sys/Dashboard")); } } else { if (user.Status == Data.ORM.Enum.Status.Deleted) { return(View()); } else { return(Redirect("/Home/Index")); } } } else { return(View()); } }
public async Task <IActionResult> Login(LoginVM loginvm) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Username və ya şifrə səhvdir!"); return(View(loginvm)); } ApplicationUser user = await _userManager.FindByNameAsync(loginvm.UserName); if (user == null) { ModelState.AddModelError("", "Username və ya şifrə səhvdir"); return(View(loginvm)); } if (user.EmailConfirmed == false) { TempData["EmailConfirm"] = true; return(RedirectToAction("Login", "Account")); } Microsoft.AspNetCore.Identity.SignInResult result = await _signInManager.PasswordSignInAsync(user, loginvm.Password, true, true); if (!result.Succeeded) { ModelState.AddModelError("", "Username və ya şifrə səhvdir"); return(View(loginvm)); } await _signInManager.SignInAsync(user, true); return(RedirectToAction("Index", "Home")); }
public async Task <IActionResult> ApiLogin(LoginVM loginVm) { var user = await _userManager.FindByNameAsync(loginVm.UserName); if (user != null) { var result = await _signInManager.PasswordSignInAsync(user, loginVm.Password, false, false); if (result.Succeeded) { var claims = new[] { new Claim(JwtRegisteredClaimNames.Sub, user.UserName), new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()) }; var SignInKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("1s5da4sd213&*^*sadjkhskjshksfd5s4fsd42^&%s7dasdfgsdfsdf4sd8f4sd8f465d%^^%$DS&")); var token = new JwtSecurityToken( issuer: "http://oec.com", audience: "http://oec.com", expires: DateTime.UtcNow.AddMinutes(15), claims: claims, signingCredentials: new SigningCredentials(SignInKey, SecurityAlgorithms.HmacSha256) ); return(Ok(new { token = new JwtSecurityTokenHandler().WriteToken(token), expiration = token.ValidTo })); } } return(Unauthorized()); }
public async Task <IActionResult> Index(LoginVM model) { if (ModelState.IsValid) { AdminUser adminuser = _newscontext.AdminUsers.FirstOrDefault(x => x.EMail == model.EMail && x.Password == model.Password); if (adminuser != null) { var claims = new List <Claim> { new Claim(ClaimTypes.Name, model.EMail), new Claim(ClaimTypes.Role, adminuser.Role), new Claim(ClaimTypes.UserData, "Admin") }; var userIdentity = new ClaimsIdentity(claims, "login"); ClaimsPrincipal principal = new ClaimsPrincipal(userIdentity); await HttpContext.SignInAsync("AdminScheme", principal); adminuser.LastLoginDate = DateTime.Now; _newscontext.SaveChanges(); return(Redirect("/Admin/Home/Index/")); } else { ViewBag.error = "Email veya şifre hatalı!"; return(View()); } } else { return(View()); } }
public ActionResult Login(LoginVM credential) { if (ModelState.IsValid) { if (_appUserService.CheckCredentials(credential.UserName, credential.Password)) { AppUser user = _appUserService.FindByUserName(credential.UserName); if (user.Status == Status.Active || user.Status == Status.Updated) { string cookie = user.UserName; FormsAuthentication.SetAuthCookie(cookie, true); // Session["ID"] = user.ID; Session["FullName"] = user.FirstName + ' ' + user.LastName; Session["ImagePath"] = user.UserImage; Session["ProfileImage"] = user.XSmallUserImage; Session["Bio"] = user.Bio; return(Redirect("/Member/Home/Index")); } else { ViewData["error"] = "Username or Password is wrong!"; return(View()); } } else { ViewData["error"] = "Username or Password is wrong!"; return(View()); } } else { TempData["class"] = "custom-hide"; return(View()); } }
public async Task <ResultVM> Login([FromBody] LoginVM model) { if (ModelState.IsValid) { var user = await _userManager.FindByNameAsync(model.UserName); if (user != null && await _userManager.CheckPasswordAsync(user, model.Password)) { var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme); identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id)); identity.AddClaim(new Claim(ClaimTypes.Name, user.UserName)); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity)); return(new ResultVM { Status = Status.Success, Message = "Succesfull login", Data = model }); } return(new ResultVM { Status = Status.Error, Message = "Invalid data", Data = "Invalid Username or Password" }); } var errors = ModelState.Keys.Select(e => e.ToString()); return(new ResultVM { Status = Status.Error, Message = "Invalid data", Data = string.Join(",", errors) }); }
async public Task <IActionResult> Login(LoginVM model) { ApplicationUser user = _context.Users.FirstOrDefault(u => u.UserName == model.Username); if (user == null) { return(RedirectToAction("AccessDenied")); } var result = await _signInManager.PasswordSignInAsync(user, model.Password, false, false); if (result.Succeeded) { var userRole = _userManager.GetRolesAsync(user).Result.Single(); if (userRole == "Administrator") { return(RedirectToAction("Index", "Home", new { area = "AdminPanel" })); } else if (userRole == "Radnik") { return(RedirectToAction("Index", "Home", new { area = "RadnikPanel" })); } else if (userRole == "Klijent") { return(RedirectToAction("Index", "Home")); } } else if (result.RequiresTwoFactor) { return(LocalRedirect("/Identity/Account/LoginWith2fa")); } return(View(model)); }
public async Task<ActionResult> Login(LoginVM model, string returnUrl) { if (!ModelState.IsValid) { return View(model); } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false); switch (result) { case SignInStatus.Success: return RedirectToLocal(returnUrl); case SignInStatus.LockedOut: return View("Lockout"); case SignInStatus.RequiresVerification: return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }); case SignInStatus.Failure: default: ModelState.AddModelError("", "无效的帐号密码"); return View(model); } }
public async Task<ActionResult> Login(LoginVM model) { try { if (ModelState.IsValid) { var user = accountManager.GetUser(model.Email); if (user != null) { if (user.Password == model.Password) { await accountManager.SaveLastLoginAsync(user.Id); int userDefaultTeamId = user.DefaultTeamId ?? 0; SetUserIDToSession(user.Id, userDefaultTeamId, user.Name); return RedirectToAction("index", "dashboard"); } } } ModelState.AddModelError("", "Username/Password is incorrect!"); } catch (Exception ex) { ModelState.AddModelError("", "Oops! Something went wrong :("); log.Error(ex); } return View(model); }
public async Task<ActionResult> Login(LoginVM model) { try { if (ModelState.IsValid) { var user = accountManager.GetUser(model.Email); if (user != null) { var appUser = new AppUser { UserName = user.EmailAddress , Id = user.Id.ToString()}; //var user1 = await um.FindAsync(model.Email, model.Password); //if (user1!= null) //{ await SignInAsync(appUser, model.RememberMe); // // return RedirectToLocal(returnUrl); //} if (user.Password == model.Password) { await accountManager.SaveLastLoginAsync(user.Id); int userDefaultTeamId = user.DefaultTeamId ?? 0; var claims = new[] { new Claim(ClaimTypes.Name, user.Name), new Claim(ClaimTypes.Email, user.EmailAddress) }; //var identity = new ClaimsIdentity(claims,DefaultAuthenticationTypes.ApplicationCookie); //ClaimsPrincipal principal = new ClaimsPrincipal(identity); //Thread.CurrentPrincipal = principal; //var context = Request.GetOwinContext(); //var authManager = context.Authentication; //authManager.SignIn(new AuthenticationProperties { IsPersistent = true }, identity); //AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie); //var identity = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie); //AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity); SetUserIDToSession(user.Id, userDefaultTeamId, user.Name); return RedirectToAction("index", "dashboard"); } } } ModelState.AddModelError("", "Username/Password is incorrect!"); } catch (Exception ex) { ModelState.AddModelError("", "Oops! Something went wrong :("); log.Error(ex); } return View(model); }