Skip to content

Check authToken and always redirect somewhere on init - #239

Merged
AndrewGable merged 6 commits into
masterfrom
marcaaron-hamflash
Aug 19, 2020
Merged

AndrewGable merged 6 commits into
masterfrom
marcaaron-hamflash

Conversation

@marcaaron

@marcaaron marcaaron commented Aug 19, 2020 •

Copy link
Copy Markdown
Contributor

Fixes #229
Fixes #235

cc @tgolen @AndrewGable in case you have a better idea about how to do this... but here's my current reasoning...

Presently, when the app inits we always navigate to the homepage by default because there is little to stop up from navigating there and redirectTo is always undefined on the very first render (technically all state is undefined on the first render).

Since the presence of an authToken should tell us if we are logged in or not I enforced that when the app inits (or we are redirecting to '/' - which we don't ever do) then we will check for the presence of an authToken and redirect to the root if we have one. If we don't have one then we'll redirect to the /signin. And when we have a redirectTo then we'll just use that.

Lmk if I am holding this completely wrong here...

Tests:

  1. Start out logged out with no authToken
  2. Navigate to the site root by entering the url directly into the browser http://localhost:8082/
  3. Verify the homepage does not momentarily flash
  4. Verify that you are able to log in and get redirected to the homepage
  5. Enter the site root into the url browser bar again
  6. Verify that you are still logged in
  7. Log out
  8. Verify you are back on the sign in page
bonus: post-prototype thoughts (for my reference, but feel free to read on)

Would love to talk about possibly leaning on React Router more for all of our navigation needs and making site navigation something that Ion doesn't really need much awareness of. There's the HOC withRouter that can be used just about anywhere to find out where we are or redirect us to someplace else.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't sign in to android Chat/hamburger flashes briefly before showing signin page

5 participants