BlueJayOne / bluejay

Amazing Ro-Tech solutions for the common developer. 100% free.
0 stars 0 forks source link

Unauthed pages flashes as authed before moving to login #14

Closed doamatto closed 1 year ago

doamatto commented 3 years ago

Describe the bug When you go to an unauthorised page (while logged out, for instance), you will see that page for a second or so, before being redirected. It would be ideal to prevent that page from loading in the first place, as the user is not authenticated.

To Reproduce Steps to reproduce the behavior:

  1. Go to a page while authorised to verify it loads
  2. Logout of BlueJay
  3. Go to the page from before while logged out
  4. A flash of a logged in view will appear, followed by the login screen

Expected behavior It should go straight to the login page, rather than flash other content first

Desktop (please complete the following information):

Additional context Untested on mobile, as of writing. Will test when I get a chance.

jackmerrill commented 3 years ago

Due to the method that SWR (next-auth) uses to check if the user is authenticated, this may not be fixable. Only way to fix this issue is if I moved to server-side rendering, or to show a blank screen until the user is checked.

doamatto commented 3 years ago

or to show a blank screen until the user is checked.

You should be able to show a loading screen interim, rather than a blank screen.