Fixed logout view bugs, refactored w/hooks #4
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.
In addition to adding some creature comforts, this PR addresses issues #2 and #3.
Key Points
account/
. Previously, logging out would lead to a redirect tohttp://localhost:8000/account/
, which is a protected route. Switching the logoutreturnTo
location fromlocation.href
towindow.location.origin
brings the user back to the public route after logging out, and also fixes the separate issue of being redirected to a page beyond the root of the protected routes (e.g.,account/settings
oraccount/billing
). This leads to an Auth0 error unless you explicitly add all of these routes toAllowed Logout URLs
- but even if you do this, a logout redirect to a protected route is probably not desirable.isLoggedIn
set tofalse
following the Auth0 authentication process. Now,isLoggedIn
is set totrue
after the user logs out and back in again.account
page, and when users log in and reach thecallback
page, they are able to navigate to the home page, account page, and logout.SessionCheck
component ingatsby-browser.js
is now tiny (~5x shorter) and easy to read. This is the first time I've toed the waters with Hooks...I'm very happy with them! Note that this requires an upgrade to Gatsby 2.5.2 to get the fix for hot-reloading with Hooks (fix(gatsby): fix hot-reloading for hooks (patch hmr) gatsbyjs/gatsby#13713).