refactor(backend:auth): improve banned user checks and simplify claim retrieval

1,000 commits in 270 days 🎉
This commit is contained in:
2026-03-10 04:09:48 -04:00
parent e0c9f1bbc1
commit 6eb4f699b5
3 changed files with 28 additions and 14 deletions
@@ -25,7 +25,11 @@ namespace SharpbinV3.Server.Authorization
if (_requireAuth && !isAuthenticated)
return Task.CompletedTask;
var isBanned = context.User.Claims.Any(c => (c.Type == ClaimTypes.Role || c.Type == "role") && c.Value == "403");
var isBanned = bool.TryParse(context.User.Claims.FirstOrDefault(c => c.Type == "is_banned")?.Value, out var parsedIsBanned)
&& parsedIsBanned;
if (!isBanned && httpContext?.GetJwtUser()?.IsBanned == true)
isBanned = true;
if (httpContext?.GetApiKeyFromContext()?.User?.IsBanned == true)
isBanned = true;