Invitation globale work

+ tests
+ new services
+ InvitationDto and IInvitationReqest
This commit is contained in:
Artemy
2025-06-24 21:20:43 +07:00
parent f99ec0b17b
commit 76094af15b
38 changed files with 483 additions and 1640 deletions
@@ -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(