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.InstanceName

@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 JobCounts { get; init; } } -} \ No newline at end of file +} diff --git a/Iceshrimp.Backend/Pages/QueueJob.cshtml.cs b/Iceshrimp.Backend/Pages/QueueJob.cshtml.cs index d664ccee..8afca872 100644 --- a/Iceshrimp.Backend/Pages/QueueJob.cshtml.cs +++ b/Iceshrimp.Backend/Pages/QueueJob.cshtml.cs @@ -26,6 +26,8 @@ public class QueueJobModel(DatabaseContext db) : PageModel return Redirect("/login"); if (!await db.Sessions.AnyAsync(p => p.Token == cookie && p.Active && p.User.IsAdmin)) return Redirect("/login"); + + Request.HttpContext.HideFooter(); Job = await db.Jobs.FirstOrDefaultAsync(p => p.Id == id) ?? throw GracefulException.NotFound($"Job {id} not found"); diff --git a/Iceshrimp.Backend/Pages/Shared/_Layout.cshtml b/Iceshrimp.Backend/Pages/Shared/_Layout.cshtml index b0d50a12..7b960782 100644 --- a/Iceshrimp.Backend/Pages/Shared/_Layout.cshtml +++ b/Iceshrimp.Backend/Pages/Shared/_Layout.cshtml @@ -1,5 +1,6 @@ @inject IOptions Instance @using Iceshrimp.Backend.Core.Configuration +@using Iceshrimp.Backend.Core.Middleware @using Microsoft.Extensions.Options @@ -18,6 +19,12 @@ @await RenderSectionAsync("scripts", false) \ No newline at end of file diff --git a/Iceshrimp.Backend/Pages/Shared/_Layout.cshtml.css b/Iceshrimp.Backend/Pages/Shared/_Layout.cshtml.css index 5f282702..40275feb 100644 --- a/Iceshrimp.Backend/Pages/Shared/_Layout.cshtml.css +++ b/Iceshrimp.Backend/Pages/Shared/_Layout.cshtml.css @@ -1 +1,3 @@ - \ No newline at end of file +.float-right { + float: right; +} \ No newline at end of file diff --git a/Iceshrimp.Backend/Pages/User.cshtml.cs b/Iceshrimp.Backend/Pages/User.cshtml.cs index 1a043ec8..b4b5609f 100644 --- a/Iceshrimp.Backend/Pages/User.cshtml.cs +++ b/Iceshrimp.Backend/Pages/User.cshtml.cs @@ -40,7 +40,6 @@ public class UserModel( InstanceName = await meta.Get(MetaEntity.InstanceName) ?? InstanceName; - //TODO: login button //TODO: user note view (respect public preview settings - don't show renotes of remote notes if set to restricted or lower) //TODO: emoji