2024-02-24 15:00:36 +00:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
2024-03-02 00:43:56 +00:00
|
|
|
using OliverBooth.Common.Data.Web.Users;
|
|
|
|
using OliverBooth.Common.Services;
|
2024-02-24 15:00:36 +00:00
|
|
|
|
|
|
|
namespace OliverBooth.Pages.Admin;
|
|
|
|
|
|
|
|
public class Index : PageModel
|
|
|
|
{
|
|
|
|
private readonly ISessionService _sessionService;
|
|
|
|
|
2024-02-25 14:16:55 +00:00
|
|
|
public Index(ISessionService sessionService)
|
2024-02-24 15:00:36 +00:00
|
|
|
{
|
|
|
|
_sessionService = sessionService;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IUser CurrentUser { get; private set; } = null!;
|
|
|
|
|
|
|
|
public IActionResult OnGet()
|
|
|
|
{
|
2024-02-25 14:16:55 +00:00
|
|
|
if (!_sessionService.TryGetCurrentUser(Request, Response, out IUser? user))
|
2024-02-24 15:00:36 +00:00
|
|
|
{
|
2024-02-25 14:16:55 +00:00
|
|
|
return RedirectToPage("/admin/login");
|
2024-02-24 15:00:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CurrentUser = user;
|
|
|
|
return Page();
|
|
|
|
}
|
|
|
|
}
|