Repository navigation
Fix: recover an admin session that expired mid-edit - #40
Merged
Merged
Conversation
An expired session surfaced as "Save failed: Unauthorised" on every attempt, with no route back to signing in. The only way out was reloading the page, which discarded whatever was in the editor at the time, and nothing on screen said that was what had happened. Intercept a 401 in ag and ap, the two helpers every admin read and write goes through, raise the sign-in overlay, and reissue the request once the session is back. The overlay is fixed positioning over the page, so a half-filled editor survives the interruption untouched. The rule is recoversSession: only a 401, and never from the two requests that signing in is made of, which would put a sign-in box on top of a sign-in box. An upstream service answering 401 arrives as a 502 carrying that status in its detail, so a failing badge does not raise one. One sign-in is shared between requests that fail together, since a settings save makes three writes in a row, and a retry is never itself retried.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
recoversSessiontoadmin-logic.js: a 401, excluding/api/auth/checkand/api/auth/login, which are the requests signing in is made of.agandap, raise the sign-in overlay through a registered handler, and reissue the request once, so the interrupted save completes itself.saveServermakes three writes in a row and each would otherwise raise its own overlay.requireLoginfromadmin-auth.js, resolving when the existing login screen reports success; the screen isposition:fixed, so the editor underneath keeps its contents.admin.jsrather than importing it intoadmin-shared.js, which the sign-in screen itself depends on.Testing
All green. Added 12 tests: 7 driving the real retry path against a stubbed fetch (retry, no-loop, decline, shared sign-in, auth-path exclusion) and 5 on the rule.
Checklist