Sync user profile (incl. picture) from token claims on validation

This commit is contained in:
2026-06-01 01:47:47 +02:00
parent ba093e7fd5
commit 032906de6b
@@ -25,16 +25,17 @@ public sealed class JwtBearerEventsHandler(IMediator mediator, ILogger<JwtBearer
var firstName = principal.FindFirstValue(ClaimTypes.GivenName); var firstName = principal.FindFirstValue(ClaimTypes.GivenName);
var lastName = principal.FindFirstValue(ClaimTypes.Surname); var lastName = principal.FindFirstValue(ClaimTypes.Surname);
var profilePictureUrl = principal.FindFirstValue("picture");
try try
{ {
await mediator.Send( await mediator.Send(
new CreateUserCommand(userId, username, firstName, lastName), new SyncUserCommand(userId, username, firstName, lastName, profilePictureUrl),
tokenValidatedContext.HttpContext.RequestAborted); tokenValidatedContext.HttpContext.RequestAborted);
} }
catch (Exception exception) catch (Exception exception)
{ {
logger.LogError(exception, "Failed to provision user {UserId} during token validation", userId); logger.LogError(exception, "Failed to sync user {UserId} during token validation", userId);
} }
} }