Add fleshed out admin page

This commit is contained in:
Josh-Heaps
2026-02-09 14:38:58 -07:00
parent 14d748de80
commit e69e5663ce
8 changed files with 788 additions and 7 deletions
+12 -3
View File
@@ -1,12 +1,21 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc;
namespace Media.JoshHeaps.Net.Pages
{
public class LandingModel : AuthenticatedPageModel
public class LandingModel(DbExecutor dbExecutor) : AuthenticatedPageModel
{
public void OnGet()
public bool IsAdmin { get; set; }
public async Task<IActionResult> OnGetAsync()
{
RequireAuthentication();
LoadUserSession();
IsAdmin = await dbExecutor.ExecuteAsync<bool>(
"SELECT EXISTS(SELECT 1 FROM app.user_roles ur JOIN app.roles r ON ur.role_id = r.id WHERE ur.user_id = @UserId AND r.name = 'admin')",
new { UserId });
return Page();
}
}
}