Add contract and user contract entities with relationships; update JWT token claims

This commit is contained in:
masoodafar-web
2025-11-16 17:17:17 +03:30
parent 75df0c1df0
commit 79e5871899
7 changed files with 1353 additions and 1 deletions

View File

@@ -18,8 +18,11 @@ public class AdminGetJwtTokenQueryHandler : IRequestHandler<AdminGetJwtTokenQuer
CancellationToken cancellationToken)
{
var user = await _context.Users
.Include(u => u.UserContracts)
.ThenInclude(u => u.Contract)
.Include(u => u.UserRoles)
.ThenInclude(ur => ur.Role)
.FirstOrDefaultAsync(f => f.Mobile == request.Username, cancellationToken);
if (user == null)
throw new Exception("Invalid username or password.");

View File

@@ -13,6 +13,8 @@ public class GetJwtTokenQueryHandler : IRequestHandler<GetJwtTokenQuery, GetJwtT
public async Task<GetJwtTokenResponseDto> Handle(GetJwtTokenQuery request, CancellationToken cancellationToken)
{
var user = await _context.Users
.Include(u => u.UserContracts)
.ThenInclude(u => u.Contract)
.Include(u => u.UserRoles)
.ThenInclude(ur => ur.Role)
.FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(User), request.Id);