Iceshrimp.NET/Iceshrimp.Backend/Pages/Index.cshtml.cs
Laura Hausmann 6fb6bbe21f
[backend/razor] Update auth gate to use the new session cookie name
It supports both the old and the new cookie name for now, allowing for a transition period.
2024-07-16 20:37:47 +02:00

29 lines
No EOL
936 B
C#

using Iceshrimp.Backend.Core.Extensions;
using Iceshrimp.Backend.Core.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace Iceshrimp.Backend.Pages;
public class IndexModel(MetaService meta) : PageModel
{
public string? ContactEmail;
public string InstanceDescription = null!;
public string InstanceName = null!;
public async Task<IActionResult> OnGet()
{
if (Request.Cookies.ContainsKey("session") || Request.Cookies.ContainsKey("sessions"))
return Partial("Shared/FrontendSPA");
var (instanceName, instanceDescription, contactEmail) =
await meta.GetMany(MetaEntity.InstanceName, MetaEntity.InstanceDescription, MetaEntity.AdminContactEmail);
InstanceName = instanceName ?? "Iceshrimp.NET";
InstanceDescription =
instanceDescription ?? "This Iceshrimp.NET instance does not appear to have a description";
ContactEmail = contactEmail;
return Page();
}
}