Ignore:
Timestamp:
06/23/26 15:20:39 (13 days ago)
Author:
kikisrbinoska <srbinoskakristina07@…>
Branches:
main
Children:
0b502c2
Parents:
d300631
Message:

Fixes for authentication and auhtorization\

Location:
ChapterX.Infrastructure
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ChapterX.Infrastructure/Repositories/ChapterRepository.cs

    rd300631 rb373fea  
    2424                .ToListAsync(cancellationToken);
    2525        }
     26
     27        public async Task<Chapter?> GetByIdWithStoryAsync(int id, CancellationToken cancellationToken = default)
     28        {
     29            return await _dbSet
     30                .Include(c => c.Story)
     31                .FirstOrDefaultAsync(c => c.Id == id, cancellationToken);
     32        }
    2633    }
    2734}
  • ChapterX.Infrastructure/Services/JwtTokenService.cs

    rd300631 rb373fea  
    2323            var credentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
    2424
     25            var role = user.Admin != null ? "Admin"
     26                : user.Writer != null ? "Writer"
     27                : "RegularUser";
     28
    2529            var claims = new[]
    2630            {
     
    2832                new Claim(JwtRegisteredClaimNames.Email, user.Email),
    2933                new Claim(JwtRegisteredClaimNames.UniqueName, user.Username),
    30                 new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())
     34                new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
     35                new Claim(ClaimTypes.Role, role)
    3136            };
    3237
Note: See TracChangeset for help on using the changeset viewer.