Skip to content

Detect when users should log in and redirect them to an optional login page ICSHWI-9267

John Sparger requested to merge login-page-and-cookies-ICSHWI-9456-rebase into develop

Despite the branch name, this merge request targets the parent story of ICSHWI-9456: ICSHWI-9267.

It makes the following behavioral changes:

  • Suggest login in certain situations using cookies
    • If it is the first time the user has ever visited the app
    • If the user has logged in in the past and opens the app
    • If the user manually logs out
  • Change the Home behavior for non-logged-in users. /home now redirects them to /iocs

It makes the following technical changes:

  • Refactor Login into LoginForm and LoginDialog
  • Add LoginView and route it at /login
  • Update APIErrorHandler to deal with 401 and 403s now returned by API:
    • Always log out on 401
    • Always try to invoke the error handler (now even for 401s)
  • Update the User hooks and contexts:
    • Don't render UserProvider's children until we have a valid response from the backend (logged in or not)
    • Fix loading state logic in useUser -- make sure the user value is set before loading is set to false
    • Incorporate logout loading in UserProvider's loading,
    • suppress snackbars errors for roles and userInfo so we don't see authentication errors when not logged in
  • Be more careful with loading logic in useAsync
    • Start with loading=true when call=true
    • Don't set loading=false until value is set
  • Refactor GlobalAppBar to use button functionality again:
    • This allows us to disable the login button on the login page
    • Make profile menu a default "button" so everything still works
  • Adds useRedirect hook to append previous path to state. Replaces history.push and history.replace
  • Fixes storybook and tests to work with these new changes.

Unfortunately there are a lot of whitespace changes in the diff. Some files got auto-formatted

Edited by John Sparger

Merge request reports