private SignInStatus SignInOrTwoFactor(IdentityUser user, bool isPersistent, string[] ipAddress) { if (!_userService.ValidateIpRestrictions(user.Id, ipAddress)) { return(SignInStatus.IpRestriction); } var id = Convert.ToString(user.Id); if (UserManager.GetTwoFactorEnabled(user.Id) && (UserManager.GetValidTwoFactorProviders(user.Id)).Count > 0 && !AuthenticationManager.TwoFactorBrowserRemembered(id)) { var identity = new ClaimsIdentity(DefaultAuthenticationTypes.TwoFactorCookie); identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, id)); AuthenticationManager.SignIn(identity); return(SignInStatus.RequiresVerification); } Task.Run(async() => await SignInAsync(user, isPersistent, false)).Wait(); user.LastLogin = DateTime.UtcNow; UserManager.Update(user); return(SignInStatus.Success); }