Add admin accounts and streamlined header UI
This commit is contained in:
@@ -34,8 +34,11 @@ internal static class EndpointHelpers
|
||||
? t[..Math.Min(t.Length, max)]
|
||||
: null;
|
||||
|
||||
public static bool IsAuthorized(HttpContext ctx, IConfiguration config)
|
||||
public static async Task<bool> IsAdmin(HttpContext ctx, AppDbContext db, IConfiguration config)
|
||||
{
|
||||
var player = await GetAuthenticatedPlayer(ctx, db);
|
||||
if (player?.IsAdmin == true) return true;
|
||||
|
||||
var provided = ctx.Request.Headers["X-Admin-Key"].FirstOrDefault()
|
||||
?? ctx.Request.Query["key"].FirstOrDefault();
|
||||
var expected = config["ADMIN_PASSWORD"];
|
||||
|
||||
Reference in New Issue
Block a user