Repository navigation
Conversation
…e the renewal answer is read as JSON /api/session/renew answers in plain text: "true", "false", or "requestLogout" when sign-in has been disabled. checkIfSessionIsActive() requests it as JSON, so "requestLogout" is a parse error and nobody who is already signed in is signed out when an administrator disables sign-in. The answer is now read as text and mapped to a session state. Signing out goes through logOut(), which does not save, so acting on "requestLogout" directly would discard a student's unsaved work, even though the session is still valid at that point and can save. Components can now register a save with registerExitSaver(); NodeComponent registers one that saves its unsaved components. When sign-in is disabled, the registered saves run, with at most ten seconds to finish, and the user is then signed out and sent to /login?loginDisabled=true. If the sign-out request fails, the next renewal tries again.
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.
When an administrator disables sign-in, nobody who is already signed in is signed out.
/api/session/renewanswers in plain text:true,false, orrequestLogoutwhen sign-in has been disabled.SessionService.checkIfSessionIsActive()requests it withhttp.get<boolean>, sorequestLogoutfails to parse as JSON, the error is not handled, and the user stays on the page as if nothing had happened.Disabling sign-in is how an administrator clears the site before maintenance, so the people it is meant to reach are exactly the ones still working.
Making the client act on
requestLogouthas a cost that this change avoids. Signing out goes throughlogOut(), which does not save, so a student in the middle of a step would lose whatever has not been auto-saved yet. Unlike an ended session, the session is still valid at this point and can save, so the work is saved first.Changes
checkSession()replacescheckIfSessionIsActive(), reads the answer as text and maps it toactive,ended,closed, orunknown.endedsigns out as before; an empty or unexpected answer keeps the user signed in.registerExitSaver()lets a component register a save to run before a closed site signs the user out.NodeComponentregisters one that stops auto-save and saves its unsaved components with the samecreateAndSaveComponentData(true)call auto-save uses.closed, the registered saves run, with at most ten seconds to finish so that a save that never answers does not keep the user in, and the user is then signed out and sent to/login?loginDisabled=true. If the sign-out request fails, the next renewal tries again, because the sign-in page would send a user whose session is still valid back into the unit.Related changes, each in its own PR:
requestLogoutto administrators too, so without it this change signs out the administrator who closed the site./login?loginDisabled=true.Test
sessionService.spec.tsdriverenewSession()throughHttpTestingControllerwith each answer the server sends, and cover the closed-site path: saving before signing out, signing out after ten seconds when a save never answers, a save that has been unregistered, a save that throws, retrying when the sign-out request fails, and the same path from an idle session. Against the currentdevelopthe closed-site case fails withExpected one matching request for criteria "Match URL: /api/logout", found none.sessionService.spec.tsand all specs undervlepass (58). In the full suite the only failure ismillisecondsToDateTime(), which depends on the machine's time zone and fails the same way without this change.