fix: use userid for jwt, migration for user roles

This commit is contained in:
2025-07-17 10:39:22 +02:00
parent f34a1ee995
commit 3cd2eff522
8 changed files with 223 additions and 4 deletions

View File

@@ -70,7 +70,7 @@ public class AuthController : ControllerBase
if (hashedFormPassword == user.PasswordHash)
{
// All set - generate the token and return it
var token = guhf.GenerateJwtToken(formUser.Email);
var token = guhf.GenerateJwtToken(user);
SuccessfulLoginDTO response = user.ToSuccessfulLoginDTO(token);
return Ok(response);

View File

@@ -32,11 +32,12 @@ public class GeneralUseHelpers(ApplicationDbContext db, IConfiguration appsettin
}
}
public string GenerateJwtToken(string username)
public string GenerateJwtToken(User user)
{
var claims = new[]
{
new Claim(JwtRegisteredClaimNames.Sub, username),
new Claim(JwtRegisteredClaimNames.Sub, user.Id.ToString()),
// new Claim(ClaimTypes.Role, )
new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())
};