30 lines
921 B
C#
30 lines
921 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.Filters;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
namespace VoidScavengers.Services.Admin.Pages;
|
|
|
|
/// <summary>
|
|
/// Base class for all admin pages that require authentication
|
|
/// </summary>
|
|
public class AdminPageModel : PageModel
|
|
{
|
|
public override void OnPageHandlerExecuting(PageHandlerExecutingContext context)
|
|
{
|
|
// Check if logged in
|
|
var adminId = HttpContext.Session.GetString("AdminId");
|
|
if (string.IsNullOrEmpty(adminId))
|
|
{
|
|
context.Result = new RedirectToPageResult("/Login");
|
|
return;
|
|
}
|
|
|
|
// Set ViewData for layout
|
|
ViewData["AdminId"] = adminId;
|
|
ViewData["AdminUsername"] = HttpContext.Session.GetString("AdminUsername");
|
|
ViewData["AdminRole"] = HttpContext.Session.GetString("AdminRole");
|
|
|
|
base.OnPageHandlerExecuting(context);
|
|
}
|
|
}
|