sfbrigade / bats-server

Routed is an app to help ambulances direct non-critical patients to hospital emergency rooms with the most availability.
https://routedapp.org/
GNU Affero General Public License v3.0
18 stars 11 forks source link

User is not properly redirected when already logged in #323

Closed francisli closed 5 months ago

francisli commented 9 months ago

Reproduce:

1) Log in to Routed, i.e. as an EMS user and end up at /ems in the URL path 2) Manually edit the url in the browser bar to remove the path and just go to / 3) Observe: app redirects to /login even though user is already logged in, and a blank screen is shown

When a hard refresh/reload of the webapp occurs, the starting state of the auth context is "not logged in", i.e. user is undefined/null, until the app has a chance to hit /api/users/me and verify that the user is logged in and get that data. Meanwhile, the app redirects to /login, but once the user is loaded, the /login route is conditionally excluded, so there's no route match and the app displays an empty page.