Repository navigation
Check authToken and always redirect somewhere on init - #239
Merged
Merged
Conversation
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.
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
redirectTois alwaysundefinedon the very first render (technically all state isundefinedon the first render).Since the presence of an
authTokenshould 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 anauthTokenand 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 aredirectTothen we'll just use that.Lmk if I am holding this completely wrong here...
Tests:
authTokenhttp://localhost:8082/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
Iondoesn't really need much awareness of. There's the HOCwithRouterthat can be used just about anywhere to find out where we are or redirect us to someplace else.