Fix CORS error by removing [Authorize] from auth user endpoint

Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-08-26 15:39:59 +00:00
parent 23fc515f3a
commit eda9c17116

View file

@ -56,13 +56,21 @@ namespace ShiftScheduler.Server.Controllers
} }
[HttpGet("user")] [HttpGet("user")]
[Authorize]
public IActionResult GetUser() public IActionResult GetUser()
{ {
var emailClaim = User.FindFirst(ClaimTypes.Email) ?? if (User.Identity?.IsAuthenticated == true)
User.FindFirst("email"); {
var emailClaim = User.FindFirst(ClaimTypes.Email) ??
User.FindFirst("email");
return Ok(new { Email = emailClaim?.Value, IsAuthenticated = true }); // Verify the user is in the authorized emails list
if (emailClaim?.Value != null && _authorizedEmails.Contains(emailClaim.Value))
{
return Ok(new { Email = emailClaim.Value, IsAuthenticated = true });
}
}
return Ok(new { Email = (string?)null, IsAuthenticated = false });
} }
} }
} }