fix: authorize verified offline data sync
Build web service image / build (push) Successful in 1m6s

This commit is contained in:
2026-09-30 13:30:48 +08:00
parent edba7d0d38
commit e8abb15f68
12 changed files with 218 additions and 22 deletions
@@ -17,6 +17,29 @@ public sealed class RemoteAccountContext
get { lock (_gate) return _snapshot; }
}
public static string? SelectActiveAccountId(
bool uiSessionAvailable,
string? preferredAccountId,
IReadOnlyCollection<RemoteAccountIdentity> identities,
IReadOnlyCollection<string> liveBoundAccountIds)
{
ArgumentNullException.ThrowIfNull(identities);
ArgumentNullException.ThrowIfNull(liveBoundAccountIds);
if (!uiSessionAvailable) return null;
var liveBoundIds = liveBoundAccountIds.ToHashSet(StringComparer.OrdinalIgnoreCase);
var eligible = identities
.Where(identity => identity.Verified && liveBoundIds.Contains(identity.AccountId))
.ToArray();
if (!string.IsNullOrWhiteSpace(preferredAccountId))
{
var preferred = eligible.FirstOrDefault(identity =>
string.Equals(identity.AccountId, preferredAccountId, StringComparison.OrdinalIgnoreCase));
if (preferred is not null) return preferred.AccountId;
}
return eligible.Length == 1 ? eligible[0].AccountId : null;
}
public RemoteAccountContextSnapshot SwitchTo(
string accountId,
IReadOnlyCollection<RemoteAccountIdentity> identities,