mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
Invitation globale work
+ tests + new services + InvitationDto and IInvitationReqest
This commit is contained in:
@@ -13,21 +13,20 @@ namespace Govor.API.Services.Authentication;
|
||||
public class JwtService : IJwtService
|
||||
{
|
||||
private JwtOption _jwtOption;
|
||||
private IInvitesRepository _invitesRepository;
|
||||
private IInvitesService _invitesService;
|
||||
|
||||
public JwtService(IOptions<JwtOption> options)
|
||||
public JwtService(IOptions<JwtOption> options, IInvitesService invitesService)
|
||||
{
|
||||
_jwtOption = options.Value;
|
||||
_invitesService = invitesService;
|
||||
}
|
||||
|
||||
public string GenerateJwtToken(User user)
|
||||
{
|
||||
var invite = _invitesRepository.FindByIdAsync(user.InviteId).Result;
|
||||
|
||||
var claims = new[]
|
||||
{
|
||||
new Claim("userID", user.Id.ToString()),
|
||||
new Claim(ClaimTypes.Role, invite.IsAdmin ? "Admin" : "User", ClaimValueTypes.String)
|
||||
new Claim(ClaimTypes.Role, _invitesService.GetRole(user).Result, ClaimValueTypes.String)
|
||||
};
|
||||
|
||||
var singing = new SigningCredentials(
|
||||
|
||||
Reference in New Issue
Block a user