Members: approve refuses no-membership/unknown accounts; neutral text for legacy suspensions (#65)
This commit is contained in:
parent
e12b8e2298
commit
1da912d5e9
5 changed files with 160 additions and 8 deletions
|
|
@ -191,9 +191,9 @@
|
|||
|
||||
@if (Model.Actor.CanManageMembership)
|
||||
{
|
||||
@if (user.Status == MembershipStatus.Suspended && !string.IsNullOrEmpty(user.SuspensionReason))
|
||||
@if (user.Status == MembershipStatus.Suspended)
|
||||
{
|
||||
<div class="muted" style="margin-top: 0.8rem;">Suspended: @user.SuspensionReason</div>
|
||||
<div class="muted" style="margin-top: 0.8rem;">@(string.IsNullOrWhiteSpace(user.SuspensionReason) ? Bifrost.Web.Pages.App.Members.IndexModel.LegacySuspensionText : "Suspended: " + user.SuspensionReason)</div>
|
||||
}
|
||||
<form method="post" asp-page-handler="@(user.Status == MembershipStatus.Suspended ? "Unsuspend" : "Suspend")" style="margin-top: 0.8rem;">
|
||||
<input type="hidden" name="userAccountId" value="@user.UserAccountId" />
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ public sealed class IndexModel(
|
|||
};
|
||||
|
||||
internal const string ApproveSuspendedNotice = "Nothing changed: a suspended account can only be lifted with Unsuspend.";
|
||||
/// <summary>Admin-only text for a Suspended row whose reason predates the SuspensionReason column; the old text is never read back from the audit trail.</summary>
|
||||
internal const string LegacySuspensionText = "Suspended before reasons were recorded";
|
||||
internal const string NoMembershipNotice = "Nothing changed: that account has no membership yet.";
|
||||
internal const string OwnAdminRoleNotice = "Nothing changed: you cannot remove or change your own platform admin role.";
|
||||
internal const string RoleOnSuspendedNotice = "Nothing changed: a suspended account's roles cannot be changed until it is unsuspended.";
|
||||
|
|
@ -119,9 +121,16 @@ public sealed class IndexModel(
|
|||
var user = await dbContext.UserAccounts
|
||||
.Include(x => x.Membership!)
|
||||
.ThenInclude(x => x.RoleAssignments)
|
||||
.SingleAsync(x => x.Id == userAccountId, cancellationToken);
|
||||
.SingleOrDefaultAsync(x => x.Id == userAccountId, cancellationToken);
|
||||
|
||||
if (user.Membership!.Status == MembershipStatus.Suspended)
|
||||
// The chat tier holds no membership by design (docs/oidc-issuer.md); approval refuses rather than inventing one.
|
||||
if (user is null || user.Membership is null)
|
||||
{
|
||||
Notice = user is null ? RefusalNotices[SuspensionOutcome.NoSuchAccount] : NoMembershipNotice;
|
||||
return RedirectToPage();
|
||||
}
|
||||
|
||||
if (user.Membership.Status == MembershipStatus.Suspended)
|
||||
{
|
||||
Notice = ApproveSuspendedNotice; // only Unsuspend lifts a suspension
|
||||
return RedirectToPage();
|
||||
|
|
@ -181,7 +190,13 @@ public sealed class IndexModel(
|
|||
var user = await dbContext.UserAccounts
|
||||
.Include(x => x.Membership!)
|
||||
.ThenInclude(x => x.RoleAssignments)
|
||||
.SingleAsync(x => x.Id == userAccountId, cancellationToken);
|
||||
.SingleOrDefaultAsync(x => x.Id == userAccountId, cancellationToken);
|
||||
|
||||
if (user is null)
|
||||
{
|
||||
Notice = RefusalNotices[SuspensionOutcome.NoSuchAccount];
|
||||
return RedirectToPage();
|
||||
}
|
||||
|
||||
if (user.Membership is null)
|
||||
{
|
||||
|
|
@ -259,7 +274,13 @@ public sealed class IndexModel(
|
|||
var user = await dbContext.UserAccounts
|
||||
.Include(x => x.Membership!)
|
||||
.ThenInclude(x => x.TierSnapshots)
|
||||
.SingleAsync(x => x.Id == userAccountId, cancellationToken);
|
||||
.SingleOrDefaultAsync(x => x.Id == userAccountId, cancellationToken);
|
||||
|
||||
if (user is null)
|
||||
{
|
||||
Notice = RefusalNotices[SuspensionOutcome.NoSuchAccount];
|
||||
return RedirectToPage();
|
||||
}
|
||||
|
||||
if (user.Membership is null)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue