public async Task <(IdentityResult Result, JwtToken Token)> Login(string username, string password) { var user = await _manager.FindByNameAsync(username); var isChecked = await _manager.CheckPasswordAsync(user, password); if (user == null || !isChecked) { throw new UnauthorizedAccessException(); } return(IdentityResult.Success(), new JwtToken { Value = CreateToken(user) }); }
public static IdentityResult ToApplicationResult(this Microsoft.AspNetCore.Identity.IdentityResult result) { return(result.Succeeded ? IdentityResult.Success() : IdentityResult.Failure(result.Errors.Select(e => e.Description))); }