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:
parent
23fc515f3a
commit
eda9c17116
1 changed files with 12 additions and 4 deletions
|
|
@ -56,13 +56,21 @@ namespace ShiftScheduler.Server.Controllers
|
|||
}
|
||||
|
||||
[HttpGet("user")]
|
||||
[Authorize]
|
||||
public IActionResult GetUser()
|
||||
{
|
||||
if (User.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue