Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

fix(console): tell an expired magic link how to recover (#1675)

xerj-orgf9993fff26ac
diff --git a/engine/crates/xerj-console-api/tests/spa_assets.rs b/engine/crates/xerj-console-api/tests/spa_assets.rs
index b90c12454..098a7253f 100644
--- a/engine/crates/xerj-console-api/tests/spa_assets.rs
+++ b/engine/crates/xerj-console-api/tests/spa_assets.rs
@@ -61,6 +61,18 @@ async fn setup_html_is_bundled_and_served() {
body.contains("one-time setup link") && body.contains("still unclaimed"),
"a setup URL with no #token= must say where the link was printed"
);
+ assert!(
+ body.contains("a new link is printed on boot"),
+ "an expired link must say that a restart prints a new one: {body}"
+ );
+ assert!(
+ body.contains("/_xerj-console/login"),
+ "an expired link must point an existing owner at login"
+ );
+ assert!(
+ body.contains("ask the admin who sent it for a new one"),
+ "an expired invite must not be told to restart the node: an invitee cannot"
+ );
}
#[tokio::test]
diff --git a/xerj-ux/setup.html b/xerj-ux/setup.html
index 1499d1ca2..7db899a30 100644
--- a/xerj-ux/setup.html
+++ b/xerj-ux/setup.html
@@ -169,7 +169,23 @@ let enrollmentSession = null;
if (enrollmentSession.role) $rolePill.textContent = enrollmentSession.role;
if (enrollmentSession.email) $email.value = enrollmentSession.email;
} catch (e) {
- showError('Could not redeem link: ' + e.message);
+ const msg = String((e && e.message) || e);
+ // Links are single-use. The node's bootstrap link lasts 30 minutes and
+ // a restart prints a fresh one only while nobody has claimed the owner
+ // account. An admin's invite (also served by this page) lasts 72 hours
+ // and only that admin can issue a new one. An existing account signs in
+ // at the login page. Other redeem failures keep the raw reason.
+ if (/invalid or expired/i.test(msg)) {
+ showError(
+ 'This link is invalid or expired. Setup links work once. ' +
+ 'If it was an invite, ask the admin who sent it for a new one (invites last 72 hours). ' +
+ 'If it was the setup link the node printed (it lasts 30 minutes) and nobody has claimed the owner account, ' +
+ 'restart the node: a new link is printed on boot. ' +
+ 'If you already have an account, sign in at /_xerj-console/login.'
+ );
+ } else {
+ showError('Could not redeem link: ' + msg);
+ }
$btnEnrol.disabled = true;
}
})();