Dont hide banned user's profiles

This commit is contained in:
jvyden 2021-12-19 23:47:00 -05:00
commit 11067d4f3a
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
2 changed files with 15 additions and 9 deletions

View file

@ -12,17 +12,24 @@
Model.ShowTitleInPage = false;
}
@if (Model.User != null && Model.User.IsAdmin && Model.ProfileUser.Banned)
@if (Model.ProfileUser.Banned)
{
<div class="ui inverted red segment">
<p>
<b>User is banned!</b>
<b>User is currently banned!</b>
</p>
<p>Reason: @Model.ProfileUser.BannedReason</p>
<a class="ui inverted button" href="/admin/user/@Model.ProfileUser.UserId/unban">
<i class="ban icon"></i>
<span>Unban User</span>
</a>
@if (Model.User != null && Model.User.IsAdmin)
{
<p>Reason: @Model.ProfileUser.BannedReason</p>
<a class="ui inverted button" href="/admin/user/@Model.ProfileUser.UserId/unban">
<i class="ban icon"></i>
<span>Unban User</span>
</a>
}
else
{
<p>For shame...</p>
}
</div>
}

View file

@ -24,9 +24,8 @@ namespace LBPUnion.ProjectLighthouse.Pages
public async Task<IActionResult> OnGet([FromRoute] int userId)
{
bool canViewBannedUsers = this.User != null && this.User.IsAdmin;
this.ProfileUser = await this.Database.Users.FirstOrDefaultAsync(u => u.UserId == userId);
if (this.ProfileUser == null || !canViewBannedUsers && this.ProfileUser.Banned) return this.NotFound();
if (this.ProfileUser == null) return this.NotFound();
this.Photos = await this.Database.Photos.OrderByDescending(p => p.Timestamp).Where(p => p.CreatorId == userId).Take(5).ToListAsync();
this.Comments = await this.Database.Comments.Include