diff --git a/Iceshrimp.Backend/Core/Middleware/AuthenticationMiddleware.cs b/Iceshrimp.Backend/Core/Middleware/AuthenticationMiddleware.cs index 59a583c4..fb9a802d 100644 --- a/Iceshrimp.Backend/Core/Middleware/AuthenticationMiddleware.cs +++ b/Iceshrimp.Backend/Core/Middleware/AuthenticationMiddleware.cs @@ -110,8 +110,9 @@ public class AuthenticateAttribute(params string[] scopes) : Attribute public static partial class HttpContextExtensions { - private const string Key = "session"; - private const string MastodonKey = "masto-session"; + private const string Key = "session"; + private const string MastodonKey = "masto-session"; + private const string HideFooterKey = "hide-login-footer"; internal static void SetSession(this HttpContext ctx, Session session) { @@ -149,4 +150,12 @@ public static partial class HttpContextExtensions { return ctx.GetUser() ?? throw new GracefulException("Failed to get user from HttpContext"); } + + public static bool ShouldHideFooter(this HttpContext ctx) + { + ctx.Items.TryGetValue(HideFooterKey, out var auth); + return auth is true; + } + + public static void HideFooter(this HttpContext ctx) => ctx.Items.Add(HideFooterKey, true); } \ No newline at end of file diff --git a/Iceshrimp.Backend/Pages/Error.cshtml.cs b/Iceshrimp.Backend/Pages/Error.cshtml.cs index 8600c9e8..e455052f 100644 --- a/Iceshrimp.Backend/Pages/Error.cshtml.cs +++ b/Iceshrimp.Backend/Pages/Error.cshtml.cs @@ -1,3 +1,4 @@ +using Iceshrimp.Backend.Core.Middleware; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; @@ -13,6 +14,7 @@ public class ErrorModel : PageModel public void OnGet() { + Request.HttpContext.HideFooter(); RequestId = HttpContext.TraceIdentifier; } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Pages/Index.cshtml b/Iceshrimp.Backend/Pages/Index.cshtml index ddb902f3..67d4bd4b 100644 --- a/Iceshrimp.Backend/Pages/Index.cshtml +++ b/Iceshrimp.Backend/Pages/Index.cshtml @@ -17,8 +17,6 @@
@Model.InstanceDescription
-Login - @if (Model.ContactEmail != null) { | Contact instance administrators diff --git a/Iceshrimp.Backend/Pages/Note.cshtml.cs b/Iceshrimp.Backend/Pages/Note.cshtml.cs index 921bd77f..f76f7603 100644 --- a/Iceshrimp.Backend/Pages/Note.cshtml.cs +++ b/Iceshrimp.Backend/Pages/Note.cshtml.cs @@ -44,8 +44,6 @@ public class NoteModel( InstanceName = await meta.Get(MetaEntity.InstanceName) ?? InstanceName; - //TODO: redirect to login (with route as url param) when public preview is disabled - //TODO: login button //TODO: thread view (respect public preview settings - don't show remote replies if set to restricted or lower) //TODO: emoji diff --git a/Iceshrimp.Backend/Pages/Queue.cshtml.cs b/Iceshrimp.Backend/Pages/Queue.cshtml.cs index 8149637b..4a635a03 100644 --- a/Iceshrimp.Backend/Pages/Queue.cshtml.cs +++ b/Iceshrimp.Backend/Pages/Queue.cshtml.cs @@ -30,6 +30,8 @@ public class QueueModel(DatabaseContext db, QueueService queueSvc) : PageModel return Redirect("/login"); if (!await db.Sessions.AnyAsync(p => p.Token == cookie && p.Active && p.User.IsAdmin)) return Redirect("/login"); + + Request.HttpContext.HideFooter(); if (queue == null) { @@ -127,4 +129,4 @@ public class QueueModel(DatabaseContext db, QueueService queueSvc) : PageModel public required string Name { get; init; } public required IReadOnlyDictionary