public override async Task <AuthenticationResult> Validate() { if (await authenticationStrategy.UserManager.IsLockedOutAsync(authenticationStrategy.IdentityUser)) { return(AuthenticationResult.NotSucceeded($"The user {authenticationStrategy.IdentityUser.Email} has been locked out.")); } return(AuthenticationResult.Succeeded()); }
public override async Task <AuthenticationResult> Validate() { var token = await CreateToken(); var tokenResult = await authenticationStrategy.UserManager.SetAuthenticationTokenAsync(authenticationStrategy.IdentityUser, nameof(JwtSecurityToken), nameof(JwtSecurityToken), token); authenticationStrategy.UserModel.Token = token; authenticationStrategy.UserModel.ExpirationDate = DateTime.UtcNow.AddDays(1); return(AuthenticationResult.Succeeded()); }
public override async Task <AuthenticationResult> Validate() { var password = authenticationStrategy.Cryptography.Decrypt(authenticationStrategy.UserModel.Password); if (!await authenticationStrategy.UserManager.CheckPasswordAsync(authenticationStrategy.IdentityUser, password)) { await authenticationStrategy.UserManager.AccessFailedAsync(authenticationStrategy.IdentityUser); return(AuthenticationResult.NotSucceeded("Invalid email or password.")); } return(AuthenticationResult.Succeeded()); }
public override async Task <AuthenticationResult> Validate() { var password = authenticationStrategy.Cryptography.Decrypt(authenticationStrategy.UserModel.Password); var result = await authenticationStrategy.SignInManager.PasswordSignInAsync(authenticationStrategy.UserModel.Email, password, true, false); if (!result.Succeeded) { return(AuthenticationResult.NotSucceeded("Invalid email or password.")); } return(AuthenticationResult.Succeeded()); }
public override async Task <AuthenticationResult> Validate() { var user = await authenticationStrategy.UserManager.FindByEmailAsync(authenticationStrategy.UserModel.Email); if (user == null) { return(AuthenticationResult.NotSucceeded("Invalid email or password.")); } else { authenticationStrategy.IdentityUser = user; return(AuthenticationResult.Succeeded()); } }