mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
async Task<string> GenerateJwtTokenAsync(User user)
This commit is contained in:
@@ -26,4 +26,11 @@ public class UsersService : IUsersAdministration
|
||||
return new List<User>();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<User> GetUserById(Guid userId)
|
||||
{
|
||||
var result = await _usersRepository.FindByIdAsync(userId);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -4,5 +4,5 @@ namespace Govor.API.Services.Authentication.Interfaces;
|
||||
|
||||
public interface IJwtService
|
||||
{
|
||||
string GenerateJwtToken(User user);
|
||||
Task<string> GenerateJwtTokenAsync(User user);
|
||||
}
|
||||
@@ -5,4 +5,5 @@ namespace Govor.API.Services.AdminsStuff.Interfaces;
|
||||
public interface IUsersAdministration
|
||||
{
|
||||
Task<List<User>> GetAllUsersAsync();
|
||||
Task<User> GetUserById(Guid userId);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class AuthService : IAccountService
|
||||
|
||||
SetRole(user, invitation);
|
||||
|
||||
return _jwtService.GenerateJwtToken(user);
|
||||
return await _jwtService.GenerateJwtTokenAsync(user);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class AuthService : IAccountService
|
||||
if (_passwordHasher.Verify(password, user.PasswordHash) == false)
|
||||
throw new LoginUserException();
|
||||
|
||||
return _jwtService.GenerateJwtToken(user);
|
||||
return await _jwtService.GenerateJwtTokenAsync(user);
|
||||
}
|
||||
|
||||
private async void SetRole(User user, Invitation invitation)
|
||||
|
||||
@@ -19,12 +19,12 @@ public class JwtService : IJwtService
|
||||
_invitesService = invitesService;
|
||||
}
|
||||
|
||||
public string GenerateJwtToken(User user)
|
||||
public async Task<string> GenerateJwtTokenAsync(User user)
|
||||
{
|
||||
var claims = new[]
|
||||
{
|
||||
new Claim("userId", user.Id.ToString()),
|
||||
new Claim(ClaimTypes.Role, _invitesService.GetRoleAsync(user).Result, ClaimValueTypes.String)
|
||||
new Claim(ClaimTypes.Role, await _invitesService.GetRoleAsync(user), ClaimValueTypes.String)
|
||||
};
|
||||
|
||||
var singing = new SigningCredentials(
|
||||
|
||||
Reference in New Issue
Block a user