Strip AccountMerge hooks across Bifrost.Web services and pages
This commit is contained in:
parent
7f226f7fb9
commit
21b7741b21
21 changed files with 242 additions and 579 deletions
|
|
@ -2,7 +2,6 @@ using System.Net;
|
|||
using Bifrost.Web.Configuration;
|
||||
using Bifrost.Web.Data;
|
||||
using Bifrost.Web.Domain;
|
||||
using Bifrost.Web.Features.Membership;
|
||||
using Bifrost.Web.Features.Shared;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
|
@ -81,30 +80,19 @@ public sealed class ConceptAppraisalService(
|
|||
? string.Empty
|
||||
: NetworkPrefix.Tag(client, opts.IPv4PrefixLength, opts.IPv6PrefixLength, opts.NetworkTagSecret);
|
||||
|
||||
// A voter resolved before a merge froze the account must not write an appraisal after it: the write gate reads standing at the write.
|
||||
Task<CastResult> Write() => voter.UserAccountId is { } voterAccountId
|
||||
? AccountMergeLedger.WriteAsAsync(
|
||||
dbContext,
|
||||
voterAccountId,
|
||||
standing => standing is null ? WriteAppraisalAsync(subject, voter, stance, tag, cancellationToken) : Task.FromResult(CastResult.NoVoter),
|
||||
cancellationToken)
|
||||
: WriteAppraisalAsync(subject, voter, stance, tag, cancellationToken);
|
||||
|
||||
try
|
||||
{
|
||||
return await Write();
|
||||
return await WriteAppraisalAsync(subject, voter, stance, tag, cancellationToken);
|
||||
}
|
||||
catch (DbUpdateException ex) when (ex.InnerException is PostgresException { SqlState: UniqueViolation })
|
||||
{
|
||||
// A concurrent cast by the same voter won the insert (and the failed save aborted the gate's transaction): go through the
|
||||
// gate again, which now finds their row and applies this stance to it, once.
|
||||
dbContext.ChangeTracker.Clear();
|
||||
if (await FindAppraisalAsync(subject.Id, voter.Key, cancellationToken) is null)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
return await Write();
|
||||
return await WriteAppraisalAsync(subject, voter, stance, tag, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ public sealed class HeimdallAuthService(
|
|||
LinkedAccountsSnapshots snapshots,
|
||||
PasskeyCeremonies ceremonies,
|
||||
PasskeyService passkeys,
|
||||
MergeProofs mergeProofs,
|
||||
Bifrost.Web.Features.Invites.ChatInviteService chatInvites)
|
||||
{
|
||||
public const string ErrorRedirect = "/?auth=heimdall-error";
|
||||
|
|
@ -231,12 +230,11 @@ public sealed class HeimdallAuthService(
|
|||
bool stepUp,
|
||||
string? target,
|
||||
CancellationToken cancellationToken,
|
||||
string? proof = null,
|
||||
string? returnPath = null) =>
|
||||
string? proof = null) =>
|
||||
StartAsync(
|
||||
provider,
|
||||
callbackBaseUrl,
|
||||
LocalReturnPath.Parse(returnPath ?? LinkReturnPath),
|
||||
LocalReturnPath.Parse(LinkReturnPath),
|
||||
requireMemberAccess: false,
|
||||
requestCookies,
|
||||
cancellationToken,
|
||||
|
|
@ -257,32 +255,6 @@ public sealed class HeimdallAuthService(
|
|||
HeimdallAttemptPurpose.ListProof, ProofProviderFor(sessionAccountId, via),
|
||||
sessionAccountId, callbackBaseUrl, requestCookies, false, null, cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// A fresh sign-in as the account signed in here, held as one side of a merge (<see cref="MergeProofs"/>). The member names the
|
||||
/// provider in <paramref name="via"/>: Bifrost never guesses one, and a sign-in through a login no account holds mints an unrelated
|
||||
/// Heimdall account. The browser returns to <paramref name="returnPath"/> with the outcome in <c>?result=</c>.
|
||||
/// </summary>
|
||||
public Task<HeimdallAuthStartResult> StartMergeProveSelfAsync(
|
||||
string sessionAccountId, string? via, string returnPath, string callbackBaseUrl,
|
||||
IEnumerable<KeyValuePair<string, string>> requestCookies, CancellationToken cancellationToken) =>
|
||||
StartProofAsync(
|
||||
HeimdallAttemptPurpose.MergeProveSelf, MergeProvider(via),
|
||||
sessionAccountId, callbackBaseUrl, requestCookies, false, null, cancellationToken, returnPath: returnPath);
|
||||
|
||||
/// <summary>
|
||||
/// A fresh sign-in as the other account of a merge. <paramref name="sessionAccountId"/> is the account that must not be the one
|
||||
/// proved: signing in again as oneself is not a second account.
|
||||
/// </summary>
|
||||
public Task<HeimdallAuthStartResult> StartMergeProveOtherAsync(
|
||||
string sessionAccountId, string? via, string returnPath, string callbackBaseUrl,
|
||||
IEnumerable<KeyValuePair<string, string>> requestCookies, CancellationToken cancellationToken) =>
|
||||
StartProofAsync(
|
||||
HeimdallAttemptPurpose.MergeProveOther, MergeProvider(via),
|
||||
sessionAccountId, callbackBaseUrl, requestCookies, false, null, cancellationToken, returnPath: returnPath);
|
||||
|
||||
private static string MergeProvider(string? via) =>
|
||||
ProofProvider(null, via) ?? throw new HeimdallAuthException("A merge proof needs the provider the member names.");
|
||||
|
||||
/// <summary>
|
||||
/// Links another provider: an ordinary sign-in as proof through a provider on the account's current list (there is no
|
||||
/// guessing without one), then the link start for <paramref name="targetProvider"/> with its bearer.
|
||||
|
|
@ -399,12 +371,6 @@ public sealed class HeimdallAuthService(
|
|||
/// <summary>What the attempt this browser holds for the nonce is for, or null when it holds none.</summary>
|
||||
public HeimdallAttemptPurpose? PurposeOf(string? cookieValue, string? nonce) => Unprotect(cookieValue, nonce)?.Purpose;
|
||||
|
||||
/// <summary>The page a merge-proof attempt began on, which a refused completion goes back to; null for every other attempt.</summary>
|
||||
public string? MergeReturnPathOf(string? cookieValue, string? nonce) =>
|
||||
Unprotect(cookieValue, nonce) is { Purpose: HeimdallAttemptPurpose.MergeProveSelf or HeimdallAttemptPurpose.MergeProveOther } attempt
|
||||
? attempt.ReturnPath.Value
|
||||
: null;
|
||||
|
||||
/// <summary>Redeems the code of an attempt and verifies the token it carries. The token is returned to the caller's stack frame and nowhere else.</summary>
|
||||
private async Task<(HeimdallVerifiedIdentity Identity, string AccessToken, HeimdallRedeemResponse Redeemed)> RedeemVerifiedAsync(
|
||||
string callbackBaseUrl, HeimdallAttempt attempt, string? code, CancellationToken cancellationToken)
|
||||
|
|
@ -602,72 +568,11 @@ public sealed class HeimdallAuthService(
|
|||
return new HeimdallLinkStep(null, cookieName, null, await UnlinkAsync(identity.AccountId, asserted.AccessToken!, attempt.Target, cancellationToken));
|
||||
}
|
||||
|
||||
case HeimdallAttemptPurpose.MergeProveSelf:
|
||||
case HeimdallAttemptPurpose.MergeProveOther:
|
||||
return new HeimdallLinkStep(
|
||||
null, cookieName, null, await RecordMergeProofAsync(callbackBaseUrl, attempt, code, cancellationToken), ReturnPath: attempt.ReturnPath.Value);
|
||||
|
||||
default:
|
||||
throw new HeimdallAuthException("Heimdall completion is not a link attempt.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Completes a merge-proof sign-in: redeems the code, reads the proven account's logins with its bearer and hands both to
|
||||
/// <see cref="MergeProofs"/>, the one place a bearer is kept. Self must prove the session's account (RedeemOwnerAsync). Other must
|
||||
/// prove a different account that has a member account here, found by its Heimdall account id and nothing else. Every refusal
|
||||
/// returns before Heimdall is asked for a list, and the bearer leaves scope with this call.
|
||||
/// </summary>
|
||||
private async Task<HeimdallLinkOutcome> RecordMergeProofAsync(
|
||||
string callbackBaseUrl, HeimdallAttempt attempt, string? code, CancellationToken cancellationToken)
|
||||
{
|
||||
var self = attempt.Purpose == HeimdallAttemptPurpose.MergeProveSelf;
|
||||
var (identity, bearer, redeemed) = self
|
||||
? await RedeemOwnerWithBodyAsync(callbackBaseUrl, attempt, code, cancellationToken)
|
||||
: await RedeemVerifiedAsync(callbackBaseUrl, attempt, code, cancellationToken);
|
||||
if (redeemed.Provider is not null && !string.Equals(redeemed.Provider, attempt.Provider, StringComparison.Ordinal))
|
||||
{
|
||||
throw new HeimdallAuthException("Heimdall completion came through another provider.");
|
||||
}
|
||||
|
||||
if (!self && string.Equals(identity.AccountId, attempt.ExpectedAccountId, StringComparison.Ordinal))
|
||||
{
|
||||
return HeimdallLinkOutcome.MergeSameAccount;
|
||||
}
|
||||
|
||||
var actorId = await UserAccountIdOfAsync(attempt.ExpectedAccountId!, cancellationToken);
|
||||
var sideId = self ? actorId : await UserAccountIdOfAsync(identity.AccountId, cancellationToken);
|
||||
if (actorId is null || sideId is null)
|
||||
{
|
||||
return HeimdallLinkOutcome.MergeNoAccount;
|
||||
}
|
||||
|
||||
var listed = await memberClient.ListAsync(bearer, cancellationToken);
|
||||
if (listed.Call != HeimdallMemberCall.Ok)
|
||||
{
|
||||
return OutcomeOf(listed.Call);
|
||||
}
|
||||
|
||||
return mergeProofs.Put(
|
||||
actorId.Value,
|
||||
self ? MergeSide.Self : MergeSide.Other,
|
||||
new MergeProof(bearer, identity.AccountId, attempt.Provider),
|
||||
sideId.Value,
|
||||
listed.Identities!) switch
|
||||
{
|
||||
PutOutcome.Stored => HeimdallLinkOutcome.MergeProofRecorded,
|
||||
PutOutcome.AmbiguousLogins => HeimdallLinkOutcome.MergeLoginsAmbiguous,
|
||||
_ => HeimdallLinkOutcome.Error
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>The member account that holds this Heimdall account id (an equality on the id, never on a name or email), or null.</summary>
|
||||
private async Task<Guid?> UserAccountIdOfAsync(string heimdallAccountId, CancellationToken cancellationToken) =>
|
||||
await dbContext.UserAccounts
|
||||
.Where(x => x.HeimdallAccountId == heimdallAccountId)
|
||||
.Select(x => (Guid?)x.Id)
|
||||
.SingleOrDefaultAsync(cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Heimdall's unlink with a bearer that carries fresh proof, and what the list becomes. Only Heimdall's definitive refusals leave
|
||||
/// the account as the list showed it. Any other end (not found, a lost answer, a 500, a malformed 200) may have applied the
|
||||
|
|
@ -924,87 +829,77 @@ public sealed class HeimdallAuthService(
|
|||
.ThenInclude(x => x.TierSnapshots)
|
||||
.SingleOrDefaultAsync(x => x.HeimdallAccountId == accountId, cancellationToken);
|
||||
|
||||
// An existing account is written as that account, through the merge ledger's write gate: a merge cannot fold it between the standing
|
||||
// read and the save. A new account has no merge to race.
|
||||
return userAccount is null
|
||||
? await PersistAsync(null)
|
||||
: await AccountMergeLedger.WriteAsAsync(dbContext, userAccount.Id, PersistAsync, cancellationToken);
|
||||
|
||||
async Task<UserAccount> PersistAsync(MergeStanding? standing)
|
||||
if (userAccount is null)
|
||||
{
|
||||
if (userAccount is null)
|
||||
userAccount = new UserAccount
|
||||
{
|
||||
userAccount = new UserAccount
|
||||
HeimdallAccountId = accountId,
|
||||
DisplayName = displayName,
|
||||
CreatedAtUtc = now,
|
||||
LastSeenAtUtc = now,
|
||||
MemberProfile = new MemberProfile
|
||||
{
|
||||
HeimdallAccountId = accountId,
|
||||
DisplayName = displayName,
|
||||
CreatedAtUtc = now,
|
||||
LastSeenAtUtc = now,
|
||||
MemberProfile = new MemberProfile
|
||||
{
|
||||
Nickname = displayName,
|
||||
Headline = $"Verified through Heimdall {provider}",
|
||||
UpdatedAtUtc = now
|
||||
},
|
||||
Membership = new Bifrost.Web.Domain.Membership
|
||||
{
|
||||
Status = grantMemberAccess ? MembershipStatus.Active : MembershipStatus.Authenticated,
|
||||
CreatedAtUtc = now,
|
||||
ApprovedAtUtc = grantMemberAccess ? now : null,
|
||||
Notes = grantMemberAccess
|
||||
? "Activated by Heimdall member access claim"
|
||||
: $"Identity verified through Heimdall {provider}"
|
||||
}
|
||||
};
|
||||
dbContext.UserAccounts.Add(userAccount);
|
||||
}
|
||||
else
|
||||
{
|
||||
userAccount.DisplayName = displayName;
|
||||
userAccount.LastSeenAtUtc = now;
|
||||
userAccount.MemberProfile ??= new MemberProfile
|
||||
{
|
||||
UserAccountId = userAccount.Id,
|
||||
Nickname = displayName,
|
||||
Headline = $"Verified through Heimdall {provider}",
|
||||
UpdatedAtUtc = now
|
||||
};
|
||||
if (userAccount.Membership is null && standing is null)
|
||||
},
|
||||
Membership = new Bifrost.Web.Domain.Membership
|
||||
{
|
||||
// Added explicitly: a row with a preset key assigned to a tracked account is taken for an existing one and the save fails.
|
||||
userAccount.Membership = new Bifrost.Web.Domain.Membership { UserAccountId = userAccount.Id, CreatedAtUtc = now };
|
||||
dbContext.Memberships.Add(userAccount.Membership);
|
||||
Status = grantMemberAccess ? MembershipStatus.Active : MembershipStatus.Authenticated,
|
||||
CreatedAtUtc = now,
|
||||
ApprovedAtUtc = grantMemberAccess ? now : null,
|
||||
Notes = grantMemberAccess
|
||||
? "Activated by Heimdall member access claim"
|
||||
: $"Identity verified through Heimdall {provider}"
|
||||
}
|
||||
|
||||
// A suspension is an admin's decision: the claim neither lifts it nor, absent, imposes it. A merged row is terminal: the claim never reactivates it.
|
||||
// A folded account, or one a merge has frozen, is an alias of its survivor: sign-in neither creates nor activates a membership for it.
|
||||
if (grantMemberAccess && standing is null && userAccount.Membership is { IsMerged: false, Status: not MembershipStatus.Suspended })
|
||||
{
|
||||
userAccount.Membership.Status = MembershipStatus.Active;
|
||||
userAccount.Membership.ApprovedAtUtc ??= now;
|
||||
}
|
||||
}
|
||||
|
||||
userAccount.MemberProfile!.Nickname = displayName;
|
||||
userAccount.MemberProfile.UpdatedAtUtc = now;
|
||||
await bifrostIdentityService.EnsureIdentityAsync(
|
||||
userAccount,
|
||||
displayName,
|
||||
cancellationToken);
|
||||
if (grantMemberAccess && userAccount.Membership is { Status: MembershipStatus.Active })
|
||||
{
|
||||
ApplicationBootstrapper.EnsureRole(
|
||||
userAccount.Membership,
|
||||
MemberRole.StandardMember,
|
||||
null,
|
||||
now,
|
||||
"Heimdall member access");
|
||||
}
|
||||
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return userAccount!;
|
||||
};
|
||||
dbContext.UserAccounts.Add(userAccount);
|
||||
}
|
||||
else
|
||||
{
|
||||
userAccount.DisplayName = displayName;
|
||||
userAccount.LastSeenAtUtc = now;
|
||||
userAccount.MemberProfile ??= new MemberProfile
|
||||
{
|
||||
UserAccountId = userAccount.Id,
|
||||
Nickname = displayName,
|
||||
Headline = $"Verified through Heimdall {provider}",
|
||||
UpdatedAtUtc = now
|
||||
};
|
||||
if (userAccount.Membership is null)
|
||||
{
|
||||
// Added explicitly: a row with a preset key assigned to a tracked account is taken for an existing one and the save fails.
|
||||
userAccount.Membership = new Bifrost.Web.Domain.Membership { UserAccountId = userAccount.Id, CreatedAtUtc = now };
|
||||
dbContext.Memberships.Add(userAccount.Membership);
|
||||
}
|
||||
|
||||
// A suspension is an admin's decision: the claim neither lifts it nor, absent, imposes it.
|
||||
if (grantMemberAccess && userAccount.Membership.Status != MembershipStatus.Suspended)
|
||||
{
|
||||
userAccount.Membership.Status = MembershipStatus.Active;
|
||||
userAccount.Membership.ApprovedAtUtc ??= now;
|
||||
}
|
||||
}
|
||||
|
||||
userAccount.MemberProfile!.Nickname = displayName;
|
||||
userAccount.MemberProfile.UpdatedAtUtc = now;
|
||||
await bifrostIdentityService.EnsureIdentityAsync(
|
||||
userAccount,
|
||||
displayName,
|
||||
cancellationToken);
|
||||
if (grantMemberAccess && userAccount.Membership is { Status: MembershipStatus.Active })
|
||||
{
|
||||
ApplicationBootstrapper.EnsureRole(
|
||||
userAccount.Membership,
|
||||
MemberRole.StandardMember,
|
||||
null,
|
||||
now,
|
||||
"Heimdall member access");
|
||||
}
|
||||
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return userAccount;
|
||||
}
|
||||
|
||||
private static HeimdallEntitlementPolicy BuildDiscordPolicy(HeimdallOptions options)
|
||||
|
|
@ -1079,8 +974,7 @@ public sealed record HeimdallAttempt(
|
|||
/// <summary>
|
||||
/// What a held attempt is for. SignIn is the default, so a cookie written before purposes existed reads as a sign-in.
|
||||
/// The other purposes belong to the Linked accounts page: the fresh sign-ins that prove an account for a list, a link or
|
||||
/// an unlink, and the provider round trips of a link. The merge purposes are fresh sign-ins that prove the account signed in here or a
|
||||
/// second one, held in <see cref="MergeProofs"/> for a merge's confirm and undo, and started by the page that is to read them. They never sign anyone in. Values are persisted in cookies: append only.
|
||||
/// an unlink, and the provider round trips of a link. Values are persisted in cookies: append only.
|
||||
/// </summary>
|
||||
public enum HeimdallAttemptPurpose
|
||||
{
|
||||
|
|
@ -1092,9 +986,7 @@ public enum HeimdallAttemptPurpose
|
|||
UnlinkProof = 5,
|
||||
LinkAwaitDirect = 6,
|
||||
EnrolProof = 7,
|
||||
UnlinkPasskeyProof = 8,
|
||||
MergeProveSelf = 9,
|
||||
MergeProveOther = 10
|
||||
UnlinkPasskeyProof = 8
|
||||
}
|
||||
|
||||
/// <summary>How a Linked accounts action ended. <see cref="HeimdallLinkOutcomes.Code"/> is its closed wire form.</summary>
|
||||
|
|
@ -1125,11 +1017,7 @@ public enum HeimdallLinkOutcome
|
|||
RateLimited,
|
||||
StepUpUnavailable,
|
||||
StepUpReplayed,
|
||||
StepUpRateLimited,
|
||||
MergeProofRecorded,
|
||||
MergeSameAccount,
|
||||
MergeNoAccount,
|
||||
MergeLoginsAmbiguous
|
||||
StepUpRateLimited
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1140,9 +1028,9 @@ public static class HeimdallLinkOutcomes
|
|||
{
|
||||
public const string ResultParameter = "result";
|
||||
|
||||
/// <summary>Back to the page that began the step (<paramref name="returnPath"/>, a local path), else the Linked accounts page.</summary>
|
||||
public static string Redirect(HeimdallLinkOutcome outcome, string? returnPath = null) =>
|
||||
(returnPath ?? HeimdallAuthService.LinkReturnPath) + "?" + ResultParameter + "=" + Code(outcome);
|
||||
/// <summary>Back to the Linked accounts page with the outcome's code.</summary>
|
||||
public static string Redirect(HeimdallLinkOutcome outcome) =>
|
||||
HeimdallAuthService.LinkReturnPath + "?" + ResultParameter + "=" + Code(outcome);
|
||||
|
||||
public static string Code(HeimdallLinkOutcome outcome) => outcome switch
|
||||
{
|
||||
|
|
@ -1171,10 +1059,6 @@ public static class HeimdallLinkOutcomes
|
|||
HeimdallLinkOutcome.StepUpUnavailable => "step_up_unavailable",
|
||||
HeimdallLinkOutcome.StepUpReplayed => "step_up_replayed",
|
||||
HeimdallLinkOutcome.StepUpRateLimited => "step_up_rate_limited",
|
||||
HeimdallLinkOutcome.MergeProofRecorded => "merge_proof_recorded",
|
||||
HeimdallLinkOutcome.MergeSameAccount => "merge_same_account",
|
||||
HeimdallLinkOutcome.MergeNoAccount => "merge_no_account",
|
||||
HeimdallLinkOutcome.MergeLoginsAmbiguous => "merge_logins_ambiguous",
|
||||
_ => "error"
|
||||
};
|
||||
|
||||
|
|
@ -1205,17 +1089,13 @@ public static class HeimdallLinkOutcomes
|
|||
"step_up_unavailable" => "Your passkey was verified, but Heimdall would not take Bifrost's proof. Nothing was changed.",
|
||||
"step_up_replayed" => "Heimdall had already seen that proof. Nothing was changed; start the unlink again.",
|
||||
"step_up_rate_limited" => "Heimdall is limiting proofs for now. Nothing was changed; wait a few minutes and start the unlink again.",
|
||||
"merge_proof_recorded" => "That sign-in is recorded for the merge. It is held in memory for a few minutes and used only when you confirm.",
|
||||
"merge_same_account" => "That sign-in is the account you are already signed in as, not a second one. Nothing was recorded.",
|
||||
"merge_no_account" => "Bifrost has no member account for that sign-in, so there is nothing to merge. Nothing was recorded.",
|
||||
"merge_logins_ambiguous" => "That account holds two logins of one provider, which Bifrost cannot prove one at a time. Nothing was recorded.",
|
||||
"list_expired" => "The list was out of date. Nothing was changed; read your linked logins again.",
|
||||
"error" => "That could not be completed. Nothing was changed.",
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
|
||||
public sealed record HeimdallLinkStep(Uri? Next, string CookieName, string? CookieValue, HeimdallLinkOutcome? Outcome, string? EnrolTicket = null, string? ReturnPath = null);
|
||||
public sealed record HeimdallLinkStep(Uri? Next, string CookieName, string? CookieValue, HeimdallLinkOutcome? Outcome, string? EnrolTicket = null);
|
||||
|
||||
public sealed record HeimdallConfirmLinkRequest(
|
||||
[property: JsonPropertyName("pendingLinkId")] string PendingLinkId);
|
||||
|
|
|
|||
|
|
@ -78,8 +78,6 @@ public sealed class HeimdallPatronSupportIntakeService(
|
|||
$"No Bifrost account is linked to Heimdall account {request.HeimdallAccountId}.");
|
||||
}
|
||||
|
||||
// The write gate behind RecordSupportEventAsync routes a folded account's event to its survivor and journals it, and on a
|
||||
// provider retry returns the stored event, journalling it if it sits on the survivor and was left unjournalled.
|
||||
var supportEvent = await patronageService.RecordSupportEventAsync(
|
||||
actorUserAccountId: null,
|
||||
userAccountId: user.Id,
|
||||
|
|
|
|||
|
|
@ -11,14 +11,7 @@ public static class HeimdallRefusal
|
|||
/// The error code in the first 4 KiB of a body when it is a short snake_case token, else null. A body that cannot be
|
||||
/// read or parsed yields null: a refusal never becomes a 500, and free text or tokens never reach a log or a page.
|
||||
/// </summary>
|
||||
public static async Task<string?> CodeAsync(HttpResponseMessage response, CancellationToken cancellationToken) =>
|
||||
(await ReadAsync(response, cancellationToken))?.Code;
|
||||
|
||||
/// <summary>
|
||||
/// The error code plus the two qualifiers a move refusal carries (the contract's `proof`, only "from" or "to", and `provider`, a
|
||||
/// short snake_case token), each kept only when it is that safe shape. Nothing else of the body is read. Null when no code reads.
|
||||
/// </summary>
|
||||
public static async Task<HeimdallRefusalBody?> ReadAsync(HttpResponseMessage response, CancellationToken cancellationToken)
|
||||
public static async Task<string?> CodeAsync(HttpResponseMessage response, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -33,8 +26,7 @@ public static class HeimdallRefusal
|
|||
using var body = JsonDocument.Parse(head.AsMemory(0, length));
|
||||
if (body.RootElement.ValueKind == JsonValueKind.Object && Token(body.RootElement, "error", 64) is { } code)
|
||||
{
|
||||
var proof = body.RootElement.TryGetProperty("proof", out var side) && side.ValueKind == JsonValueKind.String ? side.GetString() : null;
|
||||
return new HeimdallRefusalBody(code, proof is "from" or "to" ? proof : null, Token(body.RootElement, "provider", 32));
|
||||
return code;
|
||||
}
|
||||
}
|
||||
catch (Exception) when (!cancellationToken.IsCancellationRequested)
|
||||
|
|
@ -53,6 +45,3 @@ public static class HeimdallRefusal
|
|||
? text
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>A Heimdall refusal's safe fields: the code, the proof side ("from"/"to") and the provider, when present and well formed.</summary>
|
||||
public sealed record HeimdallRefusalBody(string Code, string? Proof, string? Provider);
|
||||
|
|
|
|||
|
|
@ -85,12 +85,11 @@ public sealed class ChatInviteService(BifrostDbContext db, AuditTrailService aud
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// The one reading of "invited", for every decision that asks it (token, userinfo, redemption): a redeemed chat invite, an invite carried by an
|
||||
/// account merged into this one, or an Active membership. Derived at read time, never copied to MAS or Synapse. The account needs its Membership loaded.
|
||||
/// The one reading of "invited", for every decision that asks it (token, userinfo, redemption): a redeemed chat invite
|
||||
/// or an Active membership. Derived at read time, never copied to MAS or Synapse. The account needs its Membership loaded.
|
||||
/// </summary>
|
||||
public static async Task<bool> IsInvitedAsync(BifrostDbContext db, UserAccount account, CancellationToken cancellationToken) =>
|
||||
account.ChatInvitedAtUtc is not null || new CurrentBifrostActor(true, account).IsActiveMember
|
||||
|| await Bifrost.Web.Features.Membership.AccountMergeLedger.CarriedInviteAsync(db, account.Id, cancellationToken) is not null;
|
||||
public static bool IsInvited(UserAccount account) =>
|
||||
account.ChatInvitedAtUtc is not null || new CurrentBifrostActor(true, account).IsActiveMember;
|
||||
|
||||
public void Carry(HttpContext http, string token) =>
|
||||
http.Response.Cookies.Append(CookieName, token, CookieOptions(CookieLifetime));
|
||||
|
|
@ -114,7 +113,7 @@ public sealed class ChatInviteService(BifrostDbContext db, AuditTrailService aud
|
|||
var account = await db.UserAccounts.Include(x => x.Membership).SingleOrDefaultAsync(x => x.Id == accountId, cancellationToken);
|
||||
if (invite is null || account is null
|
||||
|| invite.RedeemedAtUtc is not null || invite.RevokedAtUtc is not null || invite.ExpiresAtUtc <= now
|
||||
|| await IsInvitedAsync(db, account, cancellationToken))
|
||||
|| IsInvited(account))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,12 +49,6 @@ public sealed class MembershipSuspensionService(BifrostDbContext dbContext, Audi
|
|||
return SuspensionOutcome.NoSuchAccount;
|
||||
}
|
||||
|
||||
// A merged account is terminal: only the merge ledger leaves that status, so neither suspending nor lifting applies.
|
||||
if (membership.IsMerged)
|
||||
{
|
||||
return SuspensionOutcome.NotApplicable;
|
||||
}
|
||||
|
||||
// An admin cannot suspend themselves or another platform admin here (the same derivation that makes an actor an admin):
|
||||
// bootstrap admins are re-promoted to Active at sign-in by configuration, so the suspension would be undone without a receipt.
|
||||
if (suspend && (user.Id == actor.UserAccount.Id || new CurrentBifrostActor(true, user).IsPlatformAdmin))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using Bifrost.Web.Data;
|
||||
using Bifrost.Web.Domain;
|
||||
using Bifrost.Web.Features.Membership;
|
||||
using Bifrost.Web.Features.Shared;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
|
@ -63,43 +62,28 @@ public sealed class MotionGovernanceService(
|
|||
return;
|
||||
}
|
||||
|
||||
// An actor resolved before a merge froze this account must not write a vote after it: the write gate reads standing at the write.
|
||||
var wrote = await AccountMergeLedger.WriteAsAsync(dbContext, actorUser.Id, async standing =>
|
||||
var vote = motion.Votes.SingleOrDefault(x => x.UserAccountId == actorUser.Id);
|
||||
if (vote is null)
|
||||
{
|
||||
if (standing is not null)
|
||||
dbContext.Votes.Add(new Vote
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var vote = motion.Votes.SingleOrDefault(x => x.UserAccountId == actorUser.Id);
|
||||
if (vote is null)
|
||||
{
|
||||
dbContext.Votes.Add(new Vote
|
||||
{
|
||||
MotionId = motionId,
|
||||
UserAccountId = actorUser.Id,
|
||||
Choice = choice,
|
||||
Weight = actor.EffectiveVotingWeight,
|
||||
Comment = comment?.Trim() ?? string.Empty,
|
||||
CastAtUtc = timeProvider.GetUtcNow()
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
vote.Choice = choice;
|
||||
vote.Weight = actor.EffectiveVotingWeight;
|
||||
vote.Comment = comment?.Trim() ?? string.Empty;
|
||||
vote.CastAtUtc = timeProvider.GetUtcNow();
|
||||
}
|
||||
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
return true;
|
||||
}, cancellationToken);
|
||||
|
||||
if (!wrote)
|
||||
{
|
||||
return;
|
||||
MotionId = motionId,
|
||||
UserAccountId = actorUser.Id,
|
||||
Choice = choice,
|
||||
Weight = actor.EffectiveVotingWeight,
|
||||
Comment = comment?.Trim() ?? string.Empty,
|
||||
CastAtUtc = timeProvider.GetUtcNow()
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
vote.Choice = choice;
|
||||
vote.Weight = actor.EffectiveVotingWeight;
|
||||
vote.Comment = comment?.Trim() ?? string.Empty;
|
||||
vote.CastAtUtc = timeProvider.GetUtcNow();
|
||||
}
|
||||
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
|
||||
await auditTrailService.RecordAsync(
|
||||
actorUser.Id,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ using System.Text;
|
|||
using System.Text.RegularExpressions;
|
||||
using Bifrost.Web.Data;
|
||||
using Bifrost.Web.Domain;
|
||||
using Bifrost.Web.Features.Membership;
|
||||
using Bifrost.Web.Features.Shared;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
|
@ -100,26 +99,21 @@ public sealed class SealedBallotService(
|
|||
throw new SealedBallotException(SealedBallotFailure.Invalid, "A commitment is 64 lowercase hex characters (SHA-256).");
|
||||
}
|
||||
|
||||
var ballot = await AccountMergeLedger.WriteAsAsync(dbContext, user.Id, async standing =>
|
||||
var ballot = await dbContext.SealedBallots
|
||||
.SingleOrDefaultAsync(x => x.MotionId == motionId && x.UserAccountId == user.Id, cancellationToken);
|
||||
if (ballot is null)
|
||||
{
|
||||
RequireStanding(standing);
|
||||
var written = await dbContext.SealedBallots
|
||||
.SingleOrDefaultAsync(x => x.MotionId == motionId && x.UserAccountId == user.Id, cancellationToken);
|
||||
if (written is null)
|
||||
{
|
||||
written = new SealedBallot { MotionId = motionId, UserAccountId = user.Id };
|
||||
dbContext.SealedBallots.Add(written);
|
||||
}
|
||||
else
|
||||
{
|
||||
written.Revision++;
|
||||
}
|
||||
ballot = new SealedBallot { MotionId = motionId, UserAccountId = user.Id };
|
||||
dbContext.SealedBallots.Add(ballot);
|
||||
}
|
||||
else
|
||||
{
|
||||
ballot.Revision++;
|
||||
}
|
||||
|
||||
written.Commitment = commitment;
|
||||
written.CommittedAtUtc = now;
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
return written;
|
||||
}, cancellationToken);
|
||||
ballot.Commitment = commitment;
|
||||
ballot.CommittedAtUtc = now;
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
|
||||
await auditTrailService.RecordAsync(
|
||||
user.Id, nameof(Motion), motionId, "sealed.committed",
|
||||
|
|
@ -166,43 +160,36 @@ public sealed class SealedBallotService(
|
|||
|
||||
// RevealSeq and Status are concurrency tokens. A conflict means either the close froze the set (refuse, truthfully) or
|
||||
// another voter's reveal landed first while the window is still open (re-read the row and write again).
|
||||
// Standing is read once, under the gate's lock, which holds across every attempt: a merge cannot freeze the account between them.
|
||||
await AccountMergeLedger.WriteAsAsync(dbContext, user.Id, async standing =>
|
||||
for (var attempt = 0; ; attempt++)
|
||||
{
|
||||
RequireStanding(standing);
|
||||
for (var attempt = 0; ; attempt++)
|
||||
ballot.RevealedCandidate = candidate;
|
||||
ballot.RevealedReason = reason;
|
||||
ballot.Salt = document.Salt;
|
||||
ballot.RevealedAtUtc = now;
|
||||
motion.RevealSeq++;
|
||||
try
|
||||
{
|
||||
ballot.RevealedCandidate = candidate;
|
||||
ballot.RevealedReason = reason;
|
||||
ballot.Salt = document.Salt;
|
||||
ballot.RevealedAtUtc = now;
|
||||
motion.RevealSeq++;
|
||||
try
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
break;
|
||||
}
|
||||
catch (DbUpdateConcurrencyException error)
|
||||
{
|
||||
foreach (var entry in error.Entries)
|
||||
{
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
break;
|
||||
await entry.ReloadAsync(cancellationToken);
|
||||
}
|
||||
catch (DbUpdateConcurrencyException error)
|
||||
|
||||
if (PhaseOf(motion, now) != SealedPhase.Reveal)
|
||||
{
|
||||
foreach (var entry in error.Entries)
|
||||
{
|
||||
await entry.ReloadAsync(cancellationToken);
|
||||
}
|
||||
throw new SealedBallotException(SealedBallotFailure.WrongPhase, "The motion closed; the reveal window is over.");
|
||||
}
|
||||
|
||||
if (PhaseOf(motion, now) != SealedPhase.Reveal)
|
||||
{
|
||||
throw new SealedBallotException(SealedBallotFailure.WrongPhase, "The motion closed; the reveal window is over.");
|
||||
}
|
||||
|
||||
if (attempt >= 4)
|
||||
{
|
||||
throw new SealedBallotException(SealedBallotFailure.WrongPhase, "The reveal is contended; send it again.");
|
||||
}
|
||||
if (attempt >= 4)
|
||||
{
|
||||
throw new SealedBallotException(SealedBallotFailure.WrongPhase, "The reveal is contended; send it again.");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
await auditTrailService.RecordAsync(
|
||||
user.Id, nameof(Motion), motionId, "sealed.revealed",
|
||||
|
|
@ -373,15 +360,6 @@ public sealed class SealedBallotService(
|
|||
|
||||
private static string NameOf(UserAccount user) => user.MemberProfile?.Nickname ?? user.DisplayName;
|
||||
|
||||
// A member resolved before a merge froze the account must not write a ballot after it: the write gate reads standing at the write.
|
||||
private static void RequireStanding(MergeStanding? standing)
|
||||
{
|
||||
if (standing is not null)
|
||||
{
|
||||
throw new SealedBallotException(SealedBallotFailure.Forbidden, "An active member is required.");
|
||||
}
|
||||
}
|
||||
|
||||
private static UserAccount RequireMember(CurrentBifrostActor actor) =>
|
||||
actor is { IsActiveMember: true, UserAccount: { } user }
|
||||
? user
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ namespace Bifrost.Web.Features.Oidc;
|
|||
public static class OidcEndpoints
|
||||
{
|
||||
public const string SuspendedDescription = "The account is suspended.";
|
||||
public const string MergedDescription = "The account is part of an account merge and can no longer sign in.";
|
||||
public const string NoIdentityDescription = "The account has no Bifrost identity.";
|
||||
public const string ReservedIdentityDescription = "The account's Bifrost identity is reserved.";
|
||||
public const string ConsentRequiredDescription = "Agreement to the training notice in force is needed to speak in a recorded room.";
|
||||
|
|
@ -58,7 +57,7 @@ public static class OidcEndpoints
|
|||
// every member or governance surface keeps asking for Active itself (the Active-member policy, IsActiveMember, ActiveMemberIdAsync).
|
||||
if (actor.UserAccount is null)
|
||||
{
|
||||
return Deny(Errors.AccessDenied, actor.Merge is not null ? MergedDescription : NoIdentityDescription);
|
||||
return Deny(Errors.AccessDenied, NoIdentityDescription);
|
||||
}
|
||||
|
||||
if (actor.Membership?.Status == MembershipStatus.Suspended)
|
||||
|
|
@ -105,7 +104,7 @@ public static class OidcEndpoints
|
|||
|
||||
// Chat is by invitation: a chat token goes only to an invited account or an Active member, and an account that is neither is not
|
||||
// sent on to agree to a notice. Read again at token and userinfo time by ChatRefusalAsync; a desk token asks no invite.
|
||||
if (!IsDeskToken(principal) && !await Bifrost.Web.Features.Invites.ChatInviteService.IsInvitedAsync(db, account, http.RequestAborted))
|
||||
if (!IsDeskToken(principal) && !Bifrost.Web.Features.Invites.ChatInviteService.IsInvited(account))
|
||||
{
|
||||
return Deny(Errors.AccessDenied, NotInvitedDescription);
|
||||
}
|
||||
|
|
@ -185,18 +184,12 @@ public static class OidcEndpoints
|
|||
return SuspendedDescription;
|
||||
}
|
||||
|
||||
// A folded or frozen subject's chat sessions end: token, userinfo and the logout reconciler all read this one refusal.
|
||||
if (await AccountMergeLedger.StandingAsync(db, accountId, cancellationToken) is not null)
|
||||
{
|
||||
return MergedDescription;
|
||||
}
|
||||
|
||||
if (deskToken)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!await Bifrost.Web.Features.Invites.ChatInviteService.IsInvitedAsync(db, account, cancellationToken))
|
||||
if (!Bifrost.Web.Features.Invites.ChatInviteService.IsInvited(account))
|
||||
{
|
||||
return NotInvitedDescription;
|
||||
}
|
||||
|
|
@ -212,12 +205,6 @@ public static class OidcEndpoints
|
|||
return null;
|
||||
}
|
||||
|
||||
// A folded or frozen subject's live token acts as nobody on the desk too: the same standing the cookie gate and ChatRefusalAsync read.
|
||||
if (await AccountMergeLedger.StandingAsync(db, accountId, cancellationToken) is not null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var account = await db.UserAccounts.AsNoTracking()
|
||||
.Include(x => x.Membership)
|
||||
.SingleOrDefaultAsync(x => x.Id == accountId, cancellationToken);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using Bifrost.Web.Data;
|
||||
using Bifrost.Web.Domain;
|
||||
using Bifrost.Web.Features.Membership;
|
||||
using Bifrost.Web.Features.Shared;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
|
@ -13,11 +12,6 @@ public sealed class PatronageService(
|
|||
{
|
||||
private const string CurrentPatronIndex = "UX_TierSnapshots_MembershipId_CurrentPatron";
|
||||
|
||||
/// <summary>
|
||||
/// Records a patron event for an account, through the merge ledger's write gate: an event for a folded account lands on its survivor
|
||||
/// and is journalled in the same save (an undo moves it back); an event for a frozen account lands on it, where the commit's
|
||||
/// reduction finds it. A provider retry returns the stored event and, if it sits on a folded account's survivor, journals it once.
|
||||
/// </summary>
|
||||
public async Task<PatronSupportEvent> RecordSupportEventAsync(
|
||||
Guid? actorUserAccountId,
|
||||
Guid userAccountId,
|
||||
|
|
@ -36,128 +30,108 @@ public sealed class PatronageService(
|
|||
Guid? projectId = null)
|
||||
{
|
||||
var normalizedProviderEventId = providerEventId.Trim();
|
||||
var (supportEvent, recordedOn, isNew, recordedFor) = await AccountMergeLedger.WriteAsAsync(dbContext, userAccountId, async standing =>
|
||||
var now = timeProvider.GetUtcNow();
|
||||
|
||||
var existingProviderEvent = string.IsNullOrWhiteSpace(normalizedProviderEventId)
|
||||
? null
|
||||
: await dbContext.PatronSupportEvents
|
||||
.SingleOrDefaultAsync(x => x.Provider == provider && x.ProviderEventId == normalizedProviderEventId, cancellationToken);
|
||||
|
||||
if (existingProviderEvent is not null)
|
||||
{
|
||||
var folded = standing as MergeStanding.Folded;
|
||||
var recordOnId = folded?.SurvivorId ?? userAccountId;
|
||||
var now = timeProvider.GetUtcNow();
|
||||
|
||||
var existingProviderEvent = string.IsNullOrWhiteSpace(normalizedProviderEventId)
|
||||
? null
|
||||
: await dbContext.PatronSupportEvents
|
||||
.SingleOrDefaultAsync(x => x.Provider == provider && x.ProviderEventId == normalizedProviderEventId, cancellationToken);
|
||||
|
||||
if (existingProviderEvent is not null)
|
||||
{
|
||||
if (folded is not null && existingProviderEvent.UserAccountId == folded.SurvivorId)
|
||||
{
|
||||
await AccountMergeLedger.StageIntakeJournalAsync(dbContext, folded.MergeId, userAccountId, existingProviderEvent.Id, now, cancellationToken);
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
|
||||
return (existingProviderEvent, recordOnId, false, string.Empty);
|
||||
}
|
||||
|
||||
var user = await dbContext.UserAccounts
|
||||
.Include(x => x.Membership)
|
||||
.SingleAsync(x => x.Id == recordOnId, cancellationToken);
|
||||
|
||||
if (user.Membership is null || user.Membership.Status == MembershipStatus.Suspended)
|
||||
{
|
||||
throw new PatronSupportRefusedException();
|
||||
}
|
||||
|
||||
if (amount <= 0 && kind != PatronSupportEventKind.SupportAdjustment)
|
||||
{
|
||||
throw new InvalidOperationException("Patron support amount must be greater than zero.");
|
||||
}
|
||||
|
||||
if (amount == 0)
|
||||
{
|
||||
throw new InvalidOperationException("Patron support amount must not be zero.");
|
||||
}
|
||||
|
||||
if (kind == PatronSupportEventKind.SupportAdjustment && amount > 0)
|
||||
{
|
||||
throw new InvalidOperationException("Patron support adjustments must reduce support.");
|
||||
}
|
||||
|
||||
if (provider != ExternalPatronProvider.Manual && string.IsNullOrWhiteSpace(normalizedProviderEventId))
|
||||
{
|
||||
throw new InvalidOperationException("External patron provider events require a provider event id.");
|
||||
}
|
||||
|
||||
var normalizedCurrency = string.IsNullOrWhiteSpace(currencyCode)
|
||||
? "USD"
|
||||
: currencyCode.Trim().ToUpperInvariant();
|
||||
|
||||
if (kind == PatronSupportEventKind.RecurringSupportSnapshot && isCurrentRecurringSupport)
|
||||
{
|
||||
var existingCurrentEvents = await dbContext.PatronSupportEvents
|
||||
.Where(x => x.UserAccountId == recordOnId &&
|
||||
x.Kind == PatronSupportEventKind.RecurringSupportSnapshot &&
|
||||
x.IsCurrentRecurringSupport)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
foreach (var existing in existingCurrentEvents)
|
||||
{
|
||||
existing.IsCurrentRecurringSupport = false;
|
||||
}
|
||||
}
|
||||
|
||||
var created = new PatronSupportEvent
|
||||
{
|
||||
UserAccountId = recordOnId,
|
||||
ProjectId = projectId,
|
||||
Kind = kind,
|
||||
ExternalSupportId = externalSupportId.Trim(),
|
||||
Provider = provider,
|
||||
ProviderEventId = normalizedProviderEventId,
|
||||
ProviderPayerId = providerPayerId.Trim(),
|
||||
ProviderSubscriptionId = providerSubscriptionId.Trim(),
|
||||
Amount = amount,
|
||||
CurrencyCode = normalizedCurrency,
|
||||
IsCurrentRecurringSupport = kind == PatronSupportEventKind.RecurringSupportSnapshot && isCurrentRecurringSupport,
|
||||
SupportedAtUtc = supportedAtUtc.ToUniversalTime(),
|
||||
RecordedAtUtc = now,
|
||||
Notes = notes.Trim()
|
||||
};
|
||||
|
||||
dbContext.PatronSupportEvents.Add(created);
|
||||
dbContext.PointTransactions.Add(new PointTransaction
|
||||
{
|
||||
UserAccountId = recordOnId,
|
||||
ProjectId = projectId,
|
||||
Type = PointTransactionType.PatronSupport,
|
||||
Amount = amount,
|
||||
IsDecaying = kind == PatronSupportEventKind.OneTimeDonation,
|
||||
CreatedAtUtc = now,
|
||||
Note = $"Recorded {provider} {kind} patron support event {created.ExternalSupportId}."
|
||||
});
|
||||
|
||||
if (folded is not null)
|
||||
{
|
||||
await AccountMergeLedger.StageIntakeJournalAsync(dbContext, folded.MergeId, userAccountId, created.Id, now, cancellationToken);
|
||||
}
|
||||
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
return (created, recordOnId, true, user.DisplayName);
|
||||
}, cancellationToken);
|
||||
|
||||
if (isNew)
|
||||
{
|
||||
await auditTrailService.RecordAsync(
|
||||
actorUserAccountId,
|
||||
nameof(PatronSupportEvent),
|
||||
supportEvent.Id,
|
||||
"patron-support.recorded",
|
||||
$"Recorded {amount:0.##} {supportEvent.CurrencyCode} {provider} {kind} patron support for {recordedFor}.",
|
||||
cancellationToken);
|
||||
|
||||
await RefreshPatronTierSnapshotAsync(actorUserAccountId, recordedOn, cancellationToken);
|
||||
return existingProviderEvent;
|
||||
}
|
||||
|
||||
return supportEvent;
|
||||
var user = await dbContext.UserAccounts
|
||||
.Include(x => x.Membership)
|
||||
.SingleAsync(x => x.Id == userAccountId, cancellationToken);
|
||||
|
||||
if (user.Membership is null || user.Membership.Status == MembershipStatus.Suspended)
|
||||
{
|
||||
throw new InvalidOperationException("Patron support can only be recorded for an unsuspended Bifrost account.");
|
||||
}
|
||||
|
||||
if (amount <= 0 && kind != PatronSupportEventKind.SupportAdjustment)
|
||||
{
|
||||
throw new InvalidOperationException("Patron support amount must be greater than zero.");
|
||||
}
|
||||
|
||||
if (amount == 0)
|
||||
{
|
||||
throw new InvalidOperationException("Patron support amount must not be zero.");
|
||||
}
|
||||
|
||||
if (kind == PatronSupportEventKind.SupportAdjustment && amount > 0)
|
||||
{
|
||||
throw new InvalidOperationException("Patron support adjustments must reduce support.");
|
||||
}
|
||||
|
||||
if (provider != ExternalPatronProvider.Manual && string.IsNullOrWhiteSpace(normalizedProviderEventId))
|
||||
{
|
||||
throw new InvalidOperationException("External patron provider events require a provider event id.");
|
||||
}
|
||||
|
||||
var normalizedCurrency = string.IsNullOrWhiteSpace(currencyCode)
|
||||
? "USD"
|
||||
: currencyCode.Trim().ToUpperInvariant();
|
||||
|
||||
if (kind == PatronSupportEventKind.RecurringSupportSnapshot && isCurrentRecurringSupport)
|
||||
{
|
||||
var existingCurrentEvents = await dbContext.PatronSupportEvents
|
||||
.Where(x => x.UserAccountId == userAccountId &&
|
||||
x.Kind == PatronSupportEventKind.RecurringSupportSnapshot &&
|
||||
x.IsCurrentRecurringSupport)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
foreach (var existing in existingCurrentEvents)
|
||||
{
|
||||
existing.IsCurrentRecurringSupport = false;
|
||||
}
|
||||
}
|
||||
|
||||
var created = new PatronSupportEvent
|
||||
{
|
||||
UserAccountId = userAccountId,
|
||||
ProjectId = projectId,
|
||||
Kind = kind,
|
||||
ExternalSupportId = externalSupportId.Trim(),
|
||||
Provider = provider,
|
||||
ProviderEventId = normalizedProviderEventId,
|
||||
ProviderPayerId = providerPayerId.Trim(),
|
||||
ProviderSubscriptionId = providerSubscriptionId.Trim(),
|
||||
Amount = amount,
|
||||
CurrencyCode = normalizedCurrency,
|
||||
IsCurrentRecurringSupport = kind == PatronSupportEventKind.RecurringSupportSnapshot && isCurrentRecurringSupport,
|
||||
SupportedAtUtc = supportedAtUtc.ToUniversalTime(),
|
||||
RecordedAtUtc = now,
|
||||
Notes = notes.Trim()
|
||||
};
|
||||
|
||||
dbContext.PatronSupportEvents.Add(created);
|
||||
dbContext.PointTransactions.Add(new PointTransaction
|
||||
{
|
||||
UserAccountId = userAccountId,
|
||||
ProjectId = projectId,
|
||||
Type = PointTransactionType.PatronSupport,
|
||||
Amount = amount,
|
||||
IsDecaying = kind == PatronSupportEventKind.OneTimeDonation,
|
||||
CreatedAtUtc = now,
|
||||
Note = $"Recorded {provider} {kind} patron support event {created.ExternalSupportId}."
|
||||
});
|
||||
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
|
||||
await auditTrailService.RecordAsync(
|
||||
actorUserAccountId,
|
||||
nameof(PatronSupportEvent),
|
||||
created.Id,
|
||||
"patron-support.recorded",
|
||||
$"Recorded {amount:0.##} {created.CurrencyCode} {provider} {kind} patron support for {user.DisplayName}.",
|
||||
cancellationToken);
|
||||
|
||||
await RefreshPatronTierSnapshotAsync(actorUserAccountId, userAccountId, cancellationToken);
|
||||
|
||||
return created;
|
||||
}
|
||||
|
||||
public async Task<PatronPointSummary> RefreshPatronTierSnapshotAsync(
|
||||
|
|
@ -212,10 +186,9 @@ public sealed class PatronageService(
|
|||
|
||||
/// <summary>
|
||||
/// Derives the membership's patron tier from the events once and stages it on the tracker: demotes the current Patron snapshots
|
||||
/// and adds the new one. It never saves and never clears the tracker, so a caller can stage it inside a larger single save
|
||||
/// (the account merge ledger does).
|
||||
/// and adds the new one.
|
||||
/// </summary>
|
||||
public async Task<(PatronPointSummary Summary, PatronTierDefinition? Tier)> StageTierSnapshotAsync(
|
||||
private async Task<(PatronPointSummary Summary, PatronTierDefinition? Tier)> StageTierSnapshotAsync(
|
||||
Bifrost.Web.Domain.Membership membership,
|
||||
IEnumerable<PatronSupportEvent> events,
|
||||
DateTimeOffset now,
|
||||
|
|
@ -278,9 +251,6 @@ public sealed class PatronageService(
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>The account patron support would record on has no membership or is suspended.</summary>
|
||||
public sealed class PatronSupportRefusedException() : InvalidOperationException("Patron support can only be recorded for an unsuspended Bifrost account.");
|
||||
|
||||
public sealed record PatronPointSummary(
|
||||
decimal RecurringPoints,
|
||||
decimal HistoricalPoints,
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public sealed class StripeWebhookService(
|
|||
|
||||
var patronageAccount = await ResolvePatronageAccountAsync(session, stripeOptions, cancellationToken);
|
||||
|
||||
if (patronageAccount is null)
|
||||
if (patronageAccount?.Membership is null || patronageAccount.Membership.Status == MembershipStatus.Suspended)
|
||||
{
|
||||
return StripeWebhookResult.NotConfigured(
|
||||
"Stripe checkout session is not linked to an unsuspended Bifrost patron account.");
|
||||
|
|
@ -83,32 +83,22 @@ public sealed class StripeWebhookService(
|
|||
? "USD"
|
||||
: session.Currency.ToUpperInvariant();
|
||||
|
||||
// A checkout opened by an account that has since folded pays the survivor: the write gate behind RecordSupportEventAsync routes it.
|
||||
PatronSupportEvent supportEvent;
|
||||
try
|
||||
{
|
||||
supportEvent = await patronageService.RecordSupportEventAsync(
|
||||
actorUserAccountId: null,
|
||||
patronageAccount.Id,
|
||||
PatronSupportEventKind.OneTimeDonation,
|
||||
amount,
|
||||
currencyCode,
|
||||
session.Id,
|
||||
ExternalPatronProvider.Stripe,
|
||||
stripeEvent.Id,
|
||||
session.Customer,
|
||||
string.Empty,
|
||||
DateTimeOffset.FromUnixTimeSeconds(stripeEvent.Created),
|
||||
isCurrentRecurringSupport: false,
|
||||
BuildNotes(session),
|
||||
cancellationToken,
|
||||
projectId.ProjectId);
|
||||
}
|
||||
catch (PatronSupportRefusedException)
|
||||
{
|
||||
return StripeWebhookResult.NotConfigured(
|
||||
"Stripe checkout session is not linked to an unsuspended Bifrost patron account.");
|
||||
}
|
||||
await patronageService.RecordSupportEventAsync(
|
||||
actorUserAccountId: null,
|
||||
patronageAccount.Id,
|
||||
PatronSupportEventKind.OneTimeDonation,
|
||||
amount,
|
||||
currencyCode,
|
||||
session.Id,
|
||||
ExternalPatronProvider.Stripe,
|
||||
stripeEvent.Id,
|
||||
session.Customer,
|
||||
string.Empty,
|
||||
DateTimeOffset.FromUnixTimeSeconds(stripeEvent.Created),
|
||||
isCurrentRecurringSupport: false,
|
||||
BuildNotes(session),
|
||||
cancellationToken,
|
||||
projectId.ProjectId);
|
||||
|
||||
return StripeWebhookResult.Processed("Stripe patronage support event recorded.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,18 +55,12 @@ public sealed class ApplicationBootstrapper(
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// The one bootstrap-admin promotion, used at startup and at sign-in. A Merged or Suspended account is left exactly as it is (an admin's
|
||||
/// The one bootstrap-admin promotion, used at startup and at sign-in. A Suspended account is left exactly as it is (an admin's
|
||||
/// decision; only the suspension service lifts it) and the refusal is logged by account id. Returns whether it promoted.
|
||||
/// </summary>
|
||||
public static bool TryPromoteBootstrapAdmin(UserAccount account, DateTimeOffset now, ILogger logger)
|
||||
{
|
||||
var membership = account.Membership!;
|
||||
if (membership.IsMerged)
|
||||
{
|
||||
logger.LogWarning("Bootstrap admin promotion skipped for merged account {UserAccountId}.", account.Id);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (membership.Status == MembershipStatus.Suspended)
|
||||
{
|
||||
logger.LogWarning("Bootstrap admin promotion skipped for suspended account {UserAccountId}.", account.Id);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,9 @@
|
|||
using Bifrost.Web.Domain;
|
||||
using Bifrost.Web.Features.Membership;
|
||||
|
||||
namespace Bifrost.Web.Features.Shared;
|
||||
|
||||
public sealed record CurrentBifrostActor(bool IsAuthenticated, UserAccount? UserAccount)
|
||||
{
|
||||
/// <summary>Set when the account behind this sign-in is frozen or folded by an account merge; the actor then has no account.</summary>
|
||||
public MergeStanding? Merge { get; init; }
|
||||
|
||||
public static readonly CurrentBifrostActor Anonymous = new(false, null);
|
||||
|
||||
public Bifrost.Web.Domain.Membership? Membership => UserAccount?.Membership;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System.Security.Claims;
|
||||
using Bifrost.Web.Data;
|
||||
using Bifrost.Web.Features.Membership;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Bifrost.Web.Features.Shared;
|
||||
|
|
@ -12,8 +11,7 @@ public interface ICurrentBifrostActorAccessor
|
|||
|
||||
public sealed class CurrentBifrostActorAccessor(
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
BifrostDbContext dbContext,
|
||||
AccountMergeLedger ledger) : ICurrentBifrostActorAccessor
|
||||
BifrostDbContext dbContext) : ICurrentBifrostActorAccessor
|
||||
{
|
||||
private const string CacheKey = "Bifrost.CurrentActor";
|
||||
|
||||
|
|
@ -72,16 +70,6 @@ public sealed class CurrentBifrostActorAccessor(
|
|||
userAccount = await accounts.SingleOrDefaultAsync(x => x.GitHubUserId == gitHubUserId, cancellationToken);
|
||||
}
|
||||
|
||||
// A folded or frozen account acts as nobody on every route: this is the one gate (merge ledger standing, derived per request).
|
||||
if (userAccount is not null)
|
||||
{
|
||||
var standing = await ledger.StandingAsync(userAccount.Id, cancellationToken);
|
||||
if (standing is not null)
|
||||
{
|
||||
return Cache(httpContext, new CurrentBifrostActor(true, null) { Merge = standing });
|
||||
}
|
||||
}
|
||||
|
||||
return Cache(httpContext, new CurrentBifrostActor(true, userAccount));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ 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 ApproveMergedNotice = "Nothing changed: that account was merged into another and cannot be approved.";
|
||||
|
||||
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.";
|
||||
|
|
@ -120,12 +119,6 @@ public sealed class IndexModel(
|
|||
return RedirectToPage();
|
||||
}
|
||||
|
||||
if (user.Membership.IsMerged)
|
||||
{
|
||||
Notice = ApproveMergedNotice; // only the merge ledger leaves Merged
|
||||
return RedirectToPage();
|
||||
}
|
||||
|
||||
user.Membership.Status = MembershipStatus.Active;
|
||||
user.Membership.ApprovedAtUtc = timeProvider.GetUtcNow();
|
||||
ApplicationBootstrapper.EnsureRole(
|
||||
|
|
|
|||
|
|
@ -215,13 +215,6 @@
|
|||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (Model.MergeEnabled)
|
||||
{
|
||||
<p class="muted">
|
||||
Hold two accounts? <a asp-page="/Membership/MergeAccounts">Merge two accounts</a>
|
||||
</p>
|
||||
}
|
||||
}
|
||||
|
||||
<div class="panel-actions">
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
using System.Security.Claims;
|
||||
using Bifrost.Web.Configuration;
|
||||
using Bifrost.Web.Features.Heimdall;
|
||||
using Bifrost.Web.Features.Membership;
|
||||
using Bifrost.Web.Features.Passkeys;
|
||||
using Bifrost.Web.Features.Shared;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
|
|
@ -24,9 +22,7 @@ public sealed class LinkedAccountsModel(
|
|||
HeimdallAuthService heimdallAuthService,
|
||||
LinkedAccountsSnapshots snapshots,
|
||||
PasskeyService passkeys,
|
||||
ICurrentBifrostActorAccessor actors,
|
||||
IOptions<BifrostHostOptions> hostOptions,
|
||||
IOptions<AccountMergeOptions> mergeOptions,
|
||||
ILogger<LinkedAccountsModel> logger) : PageModel
|
||||
{
|
||||
private static readonly Dictionary<string, string> ProviderNames = new(StringComparer.Ordinal)
|
||||
|
|
@ -36,26 +32,8 @@ public sealed class LinkedAccountsModel(
|
|||
["google"] = "Google"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// A folded or frozen account manages no logins and enrols no passkey: the page's handlers all begin a Heimdall flow on the
|
||||
/// account's raw claim, so the one gate is here, on the actor accessor's standing, before any handler runs.
|
||||
/// </summary>
|
||||
public override async Task OnPageHandlerExecutionAsync(PageHandlerExecutingContext context, PageHandlerExecutionDelegate next)
|
||||
{
|
||||
if ((await actors.GetAsync(context.HttpContext.RequestAborted)).Merge is not null)
|
||||
{
|
||||
context.Result = Forbid();
|
||||
return;
|
||||
}
|
||||
|
||||
await base.OnPageHandlerExecutionAsync(context, next);
|
||||
}
|
||||
|
||||
private string? AccountId => User.FindFirstValue(BifrostClaimTypes.HeimdallAccountId) is { Length: > 0 } id ? id : null;
|
||||
|
||||
/// <summary>Whether the merge page exists on this server (a flag, dark until Heimdall can move logins).</summary>
|
||||
public bool MergeEnabled => mergeOptions.Value.Enabled;
|
||||
|
||||
/// <summary>The wording of the outcome the page was sent back with: a closed set, null for anything else.</summary>
|
||||
public string? ResultMessage { get; private set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -32,14 +32,6 @@
|
|||
</div>
|
||||
}
|
||||
|
||||
@if (Model.HasMerges)
|
||||
{
|
||||
<div class="panel-actions">
|
||||
<a class="button secondary" asp-page="/Membership/MergeStatus">Merge status</a>
|
||||
<span class="muted">See an account merge and, for seven days, undo it.</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="panel-actions">
|
||||
@if (Model.Actor.IsActiveMember)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,25 +1,17 @@
|
|||
using Bifrost.Web.Data;
|
||||
using Bifrost.Web.Domain;
|
||||
using System.Security.Claims;
|
||||
using Bifrost.Web.Features.Membership;
|
||||
using Bifrost.Web.Features.Shared;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Bifrost.Web.Pages.Membership;
|
||||
|
||||
[Authorize]
|
||||
public sealed class StatusModel(
|
||||
ICurrentBifrostActorAccessor actorAccessor,
|
||||
BifrostDbContext dbContext) : PageModel
|
||||
public sealed class StatusModel(ICurrentBifrostActorAccessor actorAccessor) : PageModel
|
||||
{
|
||||
/// <summary>Whether this session belongs to a Heimdall account whose logins the Linked accounts page can manage.</summary>
|
||||
public bool CanManageLogins => User.FindFirstValue(BifrostClaimTypes.HeimdallAccountId) is { Length: > 0 };
|
||||
|
||||
/// <summary>Whether this account is in, or was in, a merge: the link to Merge status is shown only then.</summary>
|
||||
public bool HasMerges { get; private set; }
|
||||
|
||||
public CurrentBifrostActor Actor { get; private set; } = CurrentBifrostActor.Anonymous;
|
||||
|
||||
public string StatusLabel => Actor.Membership?.Status switch
|
||||
|
|
@ -51,8 +43,5 @@ public sealed class StatusModel(
|
|||
public async Task OnGetAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
Actor = await actorAccessor.GetAsync(cancellationToken);
|
||||
HasMerges = Actor.Merge is not null
|
||||
|| (Actor.UserAccount is { } account
|
||||
&& await dbContext.AccountMerges.AnyAsync(x => x.SurvivorUserAccountId == account.Id || x.FoldedUserAccountId == account.Id, cancellationToken));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,11 +57,6 @@
|
|||
</div>
|
||||
</header>
|
||||
|
||||
@if (User.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
@await Component.InvokeAsync("MergeNotice")
|
||||
}
|
||||
|
||||
<main class="page-frame">
|
||||
@RenderBody()
|
||||
</main>
|
||||
|
|
|
|||
|
|
@ -131,13 +131,6 @@ builder.Services.AddSingleton<RegistrationRateLimit>();
|
|||
builder.Services.AddScoped<NativeRegistration>();
|
||||
builder.Services.AddScoped<Bifrost.Web.Features.Invites.ChatInviteService>();
|
||||
builder.Services.AddHostedService<SealedBallotCloser>();
|
||||
builder.Services.AddOptions<AccountMergeOptions>().BindConfiguration(AccountMergeOptions.SectionName);
|
||||
builder.Services.AddScoped<Bifrost.Web.Features.Membership.AccountMergeLedger>();
|
||||
builder.Services.AddScoped<Bifrost.Web.Features.Membership.AccountMergeSaga>();
|
||||
builder.Services.AddScoped<Bifrost.Web.Features.Membership.MergeNoticeFeed>();
|
||||
builder.Services.AddOptions<ChatNoticesOptions>().BindConfiguration(ChatNoticesOptions.SectionName);
|
||||
builder.Services.AddSingleton<Bifrost.Web.Features.Membership.MergeProofs>();
|
||||
builder.Services.AddHostedService<Bifrost.Web.Features.Membership.AccountMergeSweeper>();
|
||||
builder.Services.AddScoped<PatronageService>();
|
||||
builder.Services.AddScoped<StripeWebhookService>();
|
||||
builder.Services.AddScoped<HeimdallPatronSupportIntakeService>();
|
||||
|
|
@ -149,7 +142,7 @@ builder.Services.AddScoped<ReadinessService>();
|
|||
builder.Services.AddScoped<ApplicationBootstrapper>();
|
||||
builder.Services.AddSingleton<StartupConfigurationValidator>();
|
||||
builder.Services.AddScoped<IAuthorizationHandler, ActiveMemberAuthorizationHandler>();
|
||||
// The app-secret and member-bearer clients and the mover: no redirects (see HeimdallClientServices).
|
||||
// The app-secret and member-bearer clients: no redirects (see HeimdallClientServices).
|
||||
builder.Services.AddHeimdallClients();
|
||||
builder.Services.AddSingleton<LinkedAccountsSnapshots>();
|
||||
builder.Services.AddSingleton<Bifrost.Web.Features.Passkeys.PasskeyRelyingParty>();
|
||||
|
|
@ -881,8 +874,6 @@ app.MapPost("/api/sealed-motions/{id:guid}/mind", async (
|
|||
: await SealedCall(async () => await service.HandleAsync(id, envelope, ct));
|
||||
}).AllowAnonymous();
|
||||
|
||||
MergeNoticeEndpoints.Map(app);
|
||||
|
||||
app.MapGet("/auth/heimdall/complete", (HttpContext httpContext) =>
|
||||
{
|
||||
httpContext.Response.Headers.CacheControl = "no-store";
|
||||
|
|
@ -917,10 +908,7 @@ app.MapPost("/auth/heimdall/complete", async (
|
|||
held.Value.Value,
|
||||
form?["code"].ToString(),
|
||||
form?["pendingLinkId"].ToString(),
|
||||
// A folded or frozen account links nothing: the actor accessor's standing decides, not the raw claim.
|
||||
(await httpContext.RequestServices.GetRequiredService<ICurrentBifrostActorAccessor>().GetAsync(cancellationToken)).Merge is null
|
||||
? httpContext.User.FindFirstValue(BifrostClaimTypes.HeimdallAccountId)
|
||||
: null,
|
||||
httpContext.User.FindFirstValue(BifrostClaimTypes.HeimdallAccountId),
|
||||
cancellationToken);
|
||||
if (step.Next is not null)
|
||||
{
|
||||
|
|
@ -942,7 +930,7 @@ app.MapPost("/auth/heimdall/complete", async (
|
|||
}
|
||||
|
||||
httpContext.Response.Cookies.Delete(step.CookieName, HeimdallAttemptCookie.DeleteOptions());
|
||||
return Results.LocalRedirect(HeimdallLinkOutcomes.Redirect(step.Outcome!.Value, step.ReturnPath));
|
||||
return Results.LocalRedirect(HeimdallLinkOutcomes.Redirect(step.Outcome!.Value));
|
||||
}
|
||||
|
||||
var signIn = await heimdallAuthService.CompleteAsync(
|
||||
|
|
@ -969,7 +957,7 @@ app.MapPost("/auth/heimdall/complete", async (
|
|||
}
|
||||
|
||||
return linking
|
||||
? Results.LocalRedirect(HeimdallLinkOutcomes.Redirect(HeimdallLinkOutcome.Error, heimdallAuthService.MergeReturnPathOf(held?.Value, attempt)))
|
||||
? Results.LocalRedirect(HeimdallLinkOutcomes.Redirect(HeimdallLinkOutcome.Error))
|
||||
: Results.Redirect(HeimdallAuthService.ErrorRedirect);
|
||||
}
|
||||
}).AllowAnonymous();
|
||||
|
|
|
|||
Loading…
Reference in a new issue