fix(shifts): expose ExternalUserId in ShiftSignupDto to fix frontend signup state
Some checks failed
CI Pipeline / Backend Build & Test (pull_request) Failing after 49s
CI Pipeline / Frontend Lint, Test & Build (pull_request) Successful in 29s
CI Pipeline / Infrastructure Validation (pull_request) Successful in 3s

This commit is contained in:
WorkClub Automation
2026-03-09 14:46:35 +01:00
parent 6119506bd3
commit 867dc717cc
5 changed files with 31 additions and 10 deletions

View File

@@ -41,6 +41,20 @@ public class MemberSyncService
}
var email = httpContext.User.FindFirst("email")?.Value ?? httpContext.User.FindFirst("preferred_username")?.Value ?? "unknown@example.com";
// If not found by ExternalUserId, try to find by Email (for seeded users)
var memberByEmail = await _context.Members
.FirstOrDefaultAsync(m => m.Email == email && m.TenantId == tenantId);
if (memberByEmail != null)
{
// Update the seeded user with the real ExternalUserId
memberByEmail.ExternalUserId = externalUserId;
memberByEmail.UpdatedAt = DateTimeOffset.UtcNow;
await _context.SaveChangesAsync();
return;
}
var name = httpContext.User.FindFirst("name")?.Value ?? email.Split('@')[0];
var roleClaim = httpContext.User.FindFirst(System.Security.Claims.ClaimTypes.Role)?.Value ?? "Member";