mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
hot fix
This commit is contained in:
@@ -4,6 +4,6 @@ namespace Govor.API.Services.Authentication.Interfaces;
|
||||
|
||||
public interface IInvitesService
|
||||
{
|
||||
public Task<string> GetRole(User user);
|
||||
public Invitation Validate(string inviteCode);
|
||||
public Task<string> GetRoleAsync(User user);
|
||||
public Task<Invitation> ValidateAsync(string inviteCode);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ public class InvitesService : IInvitesService
|
||||
_invitesRepository = invitesRepository;
|
||||
}
|
||||
|
||||
public async Task<string> GetRole(User user)
|
||||
public async Task<string> GetRoleAsync(User user)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -28,21 +28,28 @@ public class InvitesService : IInvitesService
|
||||
}
|
||||
}
|
||||
|
||||
public Invitation Validate(string inviteCode)
|
||||
public async Task<Invitation> ValidateAsync(string inviteCode)
|
||||
{
|
||||
var invite = _invitesRepository.FindByCodeAsync(inviteCode).Result;
|
||||
|
||||
if (invite.EndDate < DateTime.Now ||
|
||||
invite.MaxParticipants <= invite.Users.Count)
|
||||
try
|
||||
{
|
||||
var invite = await _invitesRepository.FindByCodeAsync(inviteCode);
|
||||
|
||||
if (invite.EndDate < DateTime.Now || invite.MaxParticipants <= invite.Users.Count)
|
||||
{
|
||||
invite.IsActive = false;
|
||||
await _invitesRepository.UpdateAsync(invite);
|
||||
throw new InviteLinkInvalidException(inviteCode);
|
||||
}
|
||||
|
||||
return invite;
|
||||
}
|
||||
catch (NotFoundByKeyException<string>)
|
||||
{
|
||||
invite.IsActive = false;
|
||||
_invitesRepository.UpdateAsync(invite);
|
||||
throw new InviteLinkInvalidException(inviteCode);
|
||||
}
|
||||
|
||||
return invite;
|
||||
}
|
||||
|
||||
|
||||
public string GenerateInvitationLink(Invitation invitation)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
@@ -24,7 +24,7 @@ public class JwtService : IJwtService
|
||||
var claims = new[]
|
||||
{
|
||||
new Claim("userID", user.Id.ToString()),
|
||||
new Claim(ClaimTypes.Role, _invitesService.GetRole(user).Result, ClaimValueTypes.String)
|
||||
new Claim(ClaimTypes.Role, _invitesService.GetRoleAsync(user).Result, ClaimValueTypes.String)
|
||||
};
|
||||
|
||||
var singing = new SigningCredentials(
|
||||
|
||||
Reference in New Issue
Block a user