[backend/razor] Add login button to footer
This commit is contained in:
parent
797001233c
commit
898ea4d26c
9 changed files with 28 additions and 9 deletions
|
@ -112,6 +112,7 @@ public static partial class HttpContextExtensions
|
||||||
{
|
{
|
||||||
private const string Key = "session";
|
private const string Key = "session";
|
||||||
private const string MastodonKey = "masto-session";
|
private const string MastodonKey = "masto-session";
|
||||||
|
private const string HideFooterKey = "hide-login-footer";
|
||||||
|
|
||||||
internal static void SetSession(this HttpContext ctx, Session session)
|
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");
|
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);
|
||||||
}
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
using Iceshrimp.Backend.Core.Middleware;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
|
||||||
|
@ -13,6 +14,7 @@ public class ErrorModel : PageModel
|
||||||
|
|
||||||
public void OnGet()
|
public void OnGet()
|
||||||
{
|
{
|
||||||
|
Request.HttpContext.HideFooter();
|
||||||
RequestId = HttpContext.TraceIdentifier;
|
RequestId = HttpContext.TraceIdentifier;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,8 +17,6 @@
|
||||||
<h1>@Model.InstanceName</h1>
|
<h1>@Model.InstanceName</h1>
|
||||||
<p>@Model.InstanceDescription</p>
|
<p>@Model.InstanceDescription</p>
|
||||||
|
|
||||||
<a href="/login">Login</a>
|
|
||||||
|
|
||||||
@if (Model.ContactEmail != null)
|
@if (Model.ContactEmail != null)
|
||||||
{
|
{
|
||||||
<span>| <a href="mailto:@Model.ContactEmail">Contact instance administrators</a></span>
|
<span>| <a href="mailto:@Model.ContactEmail">Contact instance administrators</a></span>
|
||||||
|
|
|
@ -44,8 +44,6 @@ public class NoteModel(
|
||||||
|
|
||||||
InstanceName = await meta.Get(MetaEntity.InstanceName) ?? InstanceName;
|
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: thread view (respect public preview settings - don't show remote replies if set to restricted or lower)
|
||||||
//TODO: emoji
|
//TODO: emoji
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@ public class QueueModel(DatabaseContext db, QueueService queueSvc) : PageModel
|
||||||
if (!await db.Sessions.AnyAsync(p => p.Token == cookie && p.Active && p.User.IsAdmin))
|
if (!await db.Sessions.AnyAsync(p => p.Token == cookie && p.Active && p.User.IsAdmin))
|
||||||
return Redirect("/login");
|
return Redirect("/login");
|
||||||
|
|
||||||
|
Request.HttpContext.HideFooter();
|
||||||
|
|
||||||
if (queue == null)
|
if (queue == null)
|
||||||
{
|
{
|
||||||
Jobs = await db.Jobs.OrderByDescending(p => p.LastUpdatedAt).Take(20).ToListAsync();
|
Jobs = await db.Jobs.OrderByDescending(p => p.LastUpdatedAt).Take(20).ToListAsync();
|
||||||
|
|
|
@ -27,6 +27,8 @@ public class QueueJobModel(DatabaseContext db) : PageModel
|
||||||
if (!await db.Sessions.AnyAsync(p => p.Token == cookie && p.Active && p.User.IsAdmin))
|
if (!await db.Sessions.AnyAsync(p => p.Token == cookie && p.Active && p.User.IsAdmin))
|
||||||
return Redirect("/login");
|
return Redirect("/login");
|
||||||
|
|
||||||
|
Request.HttpContext.HideFooter();
|
||||||
|
|
||||||
Job = await db.Jobs.FirstOrDefaultAsync(p => p.Id == id) ??
|
Job = await db.Jobs.FirstOrDefaultAsync(p => p.Id == id) ??
|
||||||
throw GracefulException.NotFound($"Job {id} not found");
|
throw GracefulException.NotFound($"Job {id} not found");
|
||||||
return Page();
|
return Page();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
@inject IOptions<Config.InstanceSection> Instance
|
@inject IOptions<Config.InstanceSection> Instance
|
||||||
@using Iceshrimp.Backend.Core.Configuration
|
@using Iceshrimp.Backend.Core.Configuration
|
||||||
|
@using Iceshrimp.Backend.Core.Middleware
|
||||||
@using Microsoft.Extensions.Options
|
@using Microsoft.Extensions.Options
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
@ -18,6 +19,12 @@
|
||||||
@await RenderSectionAsync("scripts", false)
|
@await RenderSectionAsync("scripts", false)
|
||||||
<footer>
|
<footer>
|
||||||
<strong>Iceshrimp.NET</strong> v@(Instance.Value.Version)
|
<strong>Iceshrimp.NET</strong> v@(Instance.Value.Version)
|
||||||
|
<span class="float-right">
|
||||||
|
@if (!Context.ShouldHideFooter())
|
||||||
|
{
|
||||||
|
<a href="/login?rd=@(Context.Request.Path.ToUriComponent())">Login</a>
|
||||||
|
}
|
||||||
|
</span>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -1 +1,3 @@
|
||||||
|
.float-right {
|
||||||
|
float: right;
|
||||||
|
}
|
|
@ -40,7 +40,6 @@ public class UserModel(
|
||||||
|
|
||||||
InstanceName = await meta.Get(MetaEntity.InstanceName) ?? InstanceName;
|
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: user note view (respect public preview settings - don't show renotes of remote notes if set to restricted or lower)
|
||||||
//TODO: emoji
|
//TODO: emoji
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue