aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/dashboard
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/dashboard')
-rw-r--r--src/api/dashboard/dashboard.html14
-rw-r--r--src/api/dashboard/mod.rs8
2 files changed, 18 insertions, 4 deletions
diff --git a/src/api/dashboard/dashboard.html b/src/api/dashboard/dashboard.html
index d32fa7a..dd37f29 100644
--- a/src/api/dashboard/dashboard.html
+++ b/src/api/dashboard/dashboard.html
@@ -4374,7 +4374,19 @@ remakeForm.addEventListener("submit", event => {
.catch(error => remakeResult("Proposing failed: " + error, true));
});
-connect();
+// Opened from another member's page (`handOver`) with a token: it begins this browser's
+// session here before anything is read, with no login page in between. Without a
+// session, `obtainTokens` goes to the login page.
+(async () => {
+ if (handOver && typeof handOver.token === "string") {
+ try {
+ await tokenCall("../auth/session", handOver.token);
+ } catch (_) { /* a session of this browser's own may let it in still */ }
+ delete handOver.token;
+ }
+ connect();
+ obtainTokens();
+})();
// A page not shown (another tab, a minimised window) is paused: hidden for a while, it
// closes its stream, so the node stops building updates and asking members for their
// links for it; shown again, it reconnects. Briefly hidden, nothing changes.
diff --git a/src/api/dashboard/mod.rs b/src/api/dashboard/mod.rs
index 3a50ca6..9cf88a1 100644
--- a/src/api/dashboard/mod.rs
+++ b/src/api/dashboard/mod.rs
@@ -498,7 +498,6 @@ pub(crate) fn router(state: AppState) -> Router<AppState> {
// Its streams end when the node shuts down (`AppState::closing`).
let closing = state.closing.subscribe();
Router::new()
- .route("/admin/dashboard", get(page_html))
.route("/admin/dashboard/state", get(current_state))
.route("/admin/dashboard/events", get(events))
.route("/admin/dashboard/refresh", post(refresh))
@@ -701,8 +700,11 @@ pub(crate) async fn login_page() -> Response {
guarded(LOGIN, POLICY.get_or_init(|| content_policy(LOGIN)))
}
-/// `GET /admin/dashboard`: the page.
-async fn page_html() -> Response {
+/// `GET /admin/dashboard`: the page, without authentication, as the login page (it holds
+/// nothing; what it shows it reads with the browser's session, and without one it goes
+/// to `/login`). So a page opened from another member's comes up at once, beginning a
+/// session with the token handed over, with no login page in between.
+pub(crate) async fn page_html() -> Response {
static POLICY: OnceLock<String> = OnceLock::new();
let page = page().1.as_str();
guarded(page, POLICY.get_or_init(|| content_policy(page)))