Merge branch 'dev'
CI/CD / deploy (push) Failing after 2m1s
Details
CI/CD / deploy (push) Failing after 2m1s
Details
This commit is contained in:
commit
25aedbbb94
|
|
@ -256,27 +256,33 @@ function getKnownPersonas(): KnownPersona[] {
|
||||||
} catch { return []; }
|
} catch { return []; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Merge personas from both localStorage keys into a deduplicated list by username. */
|
/** Merge usernames from all localStorage sources into a deduplicated list. */
|
||||||
function getAllKnownUsernames(): string[] {
|
function getAllKnownUsernames(): string[] {
|
||||||
const seen = new Set<string>();
|
const seen = new Set<string>();
|
||||||
const result: string[] = [];
|
const result: string[] = [];
|
||||||
// Primary: persona list (has DID, most reliable)
|
const add = (u: string) => { if (u && !seen.has(u)) { seen.add(u); result.push(u); } };
|
||||||
for (const p of getKnownPersonas()) {
|
|
||||||
if (p.username && !seen.has(p.username)) {
|
// 1. Current session username (always first if logged in)
|
||||||
seen.add(p.username);
|
|
||||||
result.push(p.username);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Secondary: encryptid login-button known accounts
|
|
||||||
try {
|
try {
|
||||||
const accounts: { username: string }[] = JSON.parse(localStorage.getItem(KNOWN_ACCOUNTS_KEY) || "[]");
|
const raw = localStorage.getItem(SESSION_KEY);
|
||||||
for (const a of accounts) {
|
if (raw) {
|
||||||
if (a.username && !seen.has(a.username)) {
|
const session = JSON.parse(raw) as SessionState;
|
||||||
seen.add(a.username);
|
if (session?.claims?.username) add(session.claims.username);
|
||||||
result.push(a.username);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch { /* ignore */ }
|
} catch { /* ignore */ }
|
||||||
|
|
||||||
|
// 2. Cached username shortcut
|
||||||
|
try { add(localStorage.getItem("rspace-username") || ""); } catch { /* ignore */ }
|
||||||
|
|
||||||
|
// 3. Persona list (has DID, most reliable historical source)
|
||||||
|
for (const p of getKnownPersonas()) add(p.username);
|
||||||
|
|
||||||
|
// 4. encryptid login-button known accounts
|
||||||
|
try {
|
||||||
|
const accounts: { username: string }[] = JSON.parse(localStorage.getItem(KNOWN_ACCOUNTS_KEY) || "[]");
|
||||||
|
for (const a of accounts) add(a.username);
|
||||||
|
} catch { /* ignore */ }
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -309,19 +315,19 @@ function removeKnownPersona(did: string): void {
|
||||||
function autoResolveSpace(token: string, username: string): void {
|
function autoResolveSpace(token: string, username: string): void {
|
||||||
if (!username) return;
|
if (!username) return;
|
||||||
|
|
||||||
// Detect current space
|
|
||||||
const currentSpace = _getCurrentSpace();
|
const currentSpace = _getCurrentSpace();
|
||||||
|
|
||||||
if (currentSpace !== "demo") {
|
if (currentSpace !== "demo") {
|
||||||
// User followed a link to a specific space (e.g., orgname.rspace.online).
|
// User is on a specific space (their own or someone else's).
|
||||||
// Provision their personal space silently, then reload to apply the
|
// Provision their personal space silently in the background.
|
||||||
// authenticated session (clears access gates, reconnects CRDT sync, etc.).
|
// Don't redirect — they chose to be here. Just reload so the
|
||||||
|
// authenticated session takes effect (access gates, CRDT sync).
|
||||||
autoProvisionSpace(token);
|
autoProvisionSpace(token);
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On demo/landing — provision personal space and redirect there
|
// On demo/landing — provision personal space and redirect to dashboard
|
||||||
fetch("/api/spaces/auto-provision", {
|
fetch("/api/spaces/auto-provision", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -332,8 +338,7 @@ function autoResolveSpace(token: string, username: string): void {
|
||||||
.then((r) => r.json())
|
.then((r) => r.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (!data.slug) return;
|
if (!data.slug) return;
|
||||||
const moduleId = _getCurrentModule();
|
window.location.replace(_navUrl(data.slug, "rspace"));
|
||||||
window.location.replace(_navUrl(data.slug, moduleId));
|
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue