ProjectLighthouse/ProjectLighthouse.Servers.Website/Pages/Login/BannedUserPage.cshtml.cs
koko b4efba7f14
Patch account suspended page display issues (#777)
Remove excess heading and fix incorrect mod case display
2023-05-31 18:40:58 +00:00

38 lines
No EOL
1.2 KiB
C#

using JetBrains.Annotations;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Moderation.Cases;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login;
public class BannedUserPage : BaseLayout
{
public BannedUserPage(DatabaseContext database) : base(database)
{ }
public ModerationCaseEntity ModCase = null!;
[UsedImplicitly]
public async Task<IActionResult> OnGet()
{
UserEntity? user = this.Database.UserFromWebRequest(this.Request);
if (user == null) return this.Redirect("~/login");
if (!user.IsBanned) return this.Redirect("~/");
ModerationCaseEntity? modCase = await this.Database.Cases
.LastOrDefaultAsync(c => c.AffectedId == user.UserId
&& c.Type == CaseType.UserBan
&& !c.Dismissed);
if (modCase == null) return this.Redirect("~/");
this.ModCase = modCase;
return this.Page();
}
}