mirror of
https://github.com/Govor-team/Govor.git
synced 2026-09-22 18:43:00 +00:00
Stable server
was added removing messages many fixes bugs and moving to result pattern from throwing exceptions
This commit is contained in:
@@ -31,7 +31,6 @@ public class AuthService : IAccountService
|
||||
|
||||
public async Task<Result<User, Error>> RegistrationAsync(string name, string password, Invitation invitation)
|
||||
{
|
||||
|
||||
var validationResult = _usernameValidator.Validate(name);
|
||||
if (validationResult.IsFailure)
|
||||
{
|
||||
@@ -63,8 +62,8 @@ public class AuthService : IAccountService
|
||||
await _context.Users.AddAsync(user);
|
||||
|
||||
await SetRoleAsync(user, invitation);
|
||||
|
||||
// TODO: inv.participantCount -= 1; db.save();
|
||||
|
||||
invitation.Participants += 1;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Govor.Application.Exceptions.InvitesService;
|
||||
using Govor.Domain;
|
||||
using Govor.Domain.Common;
|
||||
using Govor.Domain.Models;
|
||||
@@ -24,7 +23,7 @@ public class InvitesService : IInvitesService
|
||||
|
||||
public async Task<string> GetRoleNameAsync(Guid sessionId)
|
||||
{
|
||||
var invitation = await _context.Invitations.FirstOrDefaultAsync(s => s.Id == sessionId);
|
||||
var invitation = await _context.Invitations.AsNoTracking().FirstOrDefaultAsync(s => s.Id == sessionId);
|
||||
|
||||
if (invitation == null)
|
||||
return "User";
|
||||
@@ -41,7 +40,7 @@ public class InvitesService : IInvitesService
|
||||
if (invite == null)
|
||||
return Result.Failure<Invitation>(Error.NotFound("Auth.LinkNotFount","Invitation not found."));
|
||||
|
||||
if (invite.EndDate < DateTime.Now || invite.MaxParticipants <= invite.Users.Count)
|
||||
if (invite.EndDate < DateTime.Now || invite.MaxParticipants <= invite.Users.Count || invite.MaxParticipants <= invite.Participants)
|
||||
{
|
||||
invite.IsActive = false;
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
@@ -26,7 +26,8 @@ public class JwtService : IJwtService
|
||||
{
|
||||
new Claim("userId", user.Id.ToString()),
|
||||
new Claim("sid", sessionId.ToString()),
|
||||
new Claim(ClaimTypes.Role, await _invitesService.GetRoleNameAsync(user), ClaimValueTypes.String)
|
||||
new Claim(ClaimTypes.Role, await _invitesService.GetRoleNameAsync(user))
|
||||
//new Claim(ClaimTypes.Role, await _invitesService.GetRoleNameAsync(user), ClaimValueTypes.String)
|
||||
};
|
||||
|
||||
var singing = new SigningCredentials(
|
||||
|
||||
Reference in New Issue
Block a user