fix(portal): /portal/login forwards an already-authenticated user (bd-2569) - #200
Merged
Conversation
…-2569) Teachers reported the app "logging out" whenever it was swiped from the task manager and reopened. The session was never at fault: the cookie is persistent (7-day Max-Age, Secure, httpOnly) and MainActivity.onPause() flushes the WebView cookie jar to disk, so it survives the process kill. What broke is WHERE the app lands. The OTA build boots straight to /portal/login — that path is compiled into the APK — which bypasses "/" (PortalRoot), the one route that reads the session and forwards an authenticated user onward. So a valid session met a login form on every cold start, and the only reasonable reading of that is "it logged me out". PortalRoot already documents this exact failure for the "/" case. This gives PortalLogin the same treatment, so the page is correct no matter how the user reaches it. Fixing the OTA url instead would need a Play release (it ships inside the APK) and would leave the hole open for anyone arriving at /portal/login by any other route. This ships over OTA — next app launch, no Play release. authenticated teacher -> /portal/dashboard authenticated leader -> /portal/leader (PortalRoot parity) session still loading -> render nothing (no form flash) genuinely no session -> the form, unchanged `sessionLoading` is aliased deliberately: the component already had a `loading` state for the submit button, and the two mean different things. Tests red-first: 4 failing before (the 5th, ordinary login, passed throughout and still does), 15 files / 81 tests green after. Build clean — which is the check that would have caught the loading-rename colliding with the submit state.
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.
Teachers reported the app "logging out" whenever it was swiped from the task manager and reopened.
The session was never at fault
The cookie is persistent (7-day
Max-Age,Secure,httpOnly) andMainActivity.onPause()flushes the WebView cookie jar to disk, so it survives the process kill.What broke is where the app lands. The OTA build boots straight to
/portal/login— that path is compiled into the APK — which bypasses/(PortalRoot), the one route that reads the session and forwards an authenticated user onward. A valid session met a login form on every cold start, and the only reasonable reading of that is "it logged me out".PortalRoot.tsxalready documents this exact failure for the/case. This givesPortalLoginthe same treatment, so the page is correct however the user reaches it.Why not just change the OTA url?
/portal/loginby any other routeThis ships over OTA — next app launch, no Play release.
Behaviour
Red-first: 4 failing → 15 files / 81 tests green. The 5th test (ordinary login) passed throughout and still does. Build verified — that's the check for the
sessionLoadingalias colliding with the existing submit-buttonloadingstate.Closes: bd-2569
🤖 Generated with Claude Code