diff --git a/src/CMSMicroservice.Application/UserCQ/Commands/VerifyOtpToken/VerifyOtpTokenCommandHandler.cs b/src/CMSMicroservice.Application/UserCQ/Commands/VerifyOtpToken/VerifyOtpTokenCommandHandler.cs index c23641a..9f5d42f 100644 --- a/src/CMSMicroservice.Application/UserCQ/Commands/VerifyOtpToken/VerifyOtpTokenCommandHandler.cs +++ b/src/CMSMicroservice.Application/UserCQ/Commands/VerifyOtpToken/VerifyOtpTokenCommandHandler.cs @@ -5,10 +5,12 @@ namespace CMSMicroservice.Application.UserCQ.Commands.VerifyOtpToken; public class VerifyOtpTokenCommandHandler : IRequestHandler { private readonly IApplicationDbContext _context; + private readonly IGenerateJwtToken _generateJwt; - public VerifyOtpTokenCommandHandler(IApplicationDbContext context) + public VerifyOtpTokenCommandHandler(IApplicationDbContext context, IGenerateJwtToken generateJwt) { _context = context; + _generateJwt = generateJwt; } public async Task Handle(VerifyOtpTokenCommand request, CancellationToken cancellationToken) @@ -22,6 +24,11 @@ public class VerifyOtpTokenCommandHandler : IRequestHandler u.UserContracts) + .ThenInclude(uc => uc.Contract) + .Include(u => u.UserRoles) + .ThenInclude(ur => ur.Role) + .Include(u => u.ClubMembership) .Where(x => x.Mobile == request.Mobile) .FirstOrDefaultAsync(cancellationToken); @@ -32,12 +39,14 @@ public class VerifyOtpTokenCommandHandler : IRequestHandler u.UserContracts) - .ThenInclude(u => u.Contract) + .ThenInclude(uc => uc.Contract) .Include(u => u.UserRoles) - .ThenInclude(ur => ur.Role) + .ThenInclude(ur => ur.Role) .Include(u => u.ClubMembership) .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(User), request.Id); return new GetJwtTokenResponseDto() diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ContractConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ContractConfiguration.cs index c310892..bbf2895 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ContractConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/ContractConfiguration.cs @@ -15,6 +15,8 @@ public class ContractConfiguration : IEntityTypeConfiguration builder.Property(entity => entity.Description).IsRequired(true); builder.Property(entity => entity.HtmlContent).IsRequired(true); builder.Property(entity => entity.Type).IsRequired(true); - + + // Map legacy Code column from database as shadow property (not used in C# code) + builder.Property("Code").IsRequired(false); } } diff --git a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/OtpTokenConfiguration.cs b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/OtpTokenConfiguration.cs index e80d5ae..9bfb65c 100644 --- a/src/CMSMicroservice.Infrastructure/Persistence/Configurations/OtpTokenConfiguration.cs +++ b/src/CMSMicroservice.Infrastructure/Persistence/Configurations/OtpTokenConfiguration.cs @@ -13,6 +13,10 @@ public class OtpTokenConfiguration : IEntityTypeConfiguration builder.Property(entity => entity.Id).UseIdentityColumn(); builder.Property(entity => entity.Mobile).IsRequired(true); builder.Property(entity => entity.Purpose).IsRequired(true); + + // Code is not persisted to database, only used in-memory before hashing + builder.Ignore(entity => entity.Code); + builder.Property(entity => entity.CodeHash).IsRequired(true); builder.Property(entity => entity.ExpiresAt).IsRequired(true); builder.Property(entity => entity.Attempts).IsRequired(true);