Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed logout view bugs, refactored w/hooks #4

Merged
merged 13 commits into from
Aug 7, 2019

Conversation

NWRichmond
Copy link
Contributor

@NWRichmond NWRichmond commented Jul 27, 2019

In addition to adding some creature comforts, this PR addresses issues #2 and #3.

Key Points

  • Logout View: Now once a user logs out, they are brought back to the home page, and are able to log in again by trying to access the protected routes in account/. Previously, logging out would lead to a redirect to http://localhost:8000/account/, which is a protected route. Switching the logout returnTo location from location.href to window.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 or account/billing). This leads to an Auth0 error unless you explicitly add all of these routes to Allowed Logout URLs - but even if you do this, a logout redirect to a protected route is probably not desirable.
  • Improved Re-Login Behavior: After logging out and attempting to access a protected route again, Auth0 login was triggered, but there was a bug which kept isLoggedIn set to false following the Auth0 authentication process. Now, isLoggedIn is set to true after the user logs out and back in again.
  • Easier Navigation: Logged-in users have access to the home page (unprotected route) via the account page, and when users log in and reach the callback page, they are able to navigate to the home page, account page, and logout.
  • Refactored With Hooks: The SessionCheck component in gatsby-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).
  • Helpful Hints in README: Guidance about Auth0 application settings and working with Gatsby environment variables are added to the README.

@NWRichmond
Copy link
Contributor Author

NWRichmond commented Jul 29, 2019

Here's a quick demo:

gatsby-auth0-demo-sansAuth

@jlengstorf jlengstorf merged commit 4188daa into jlengstorf:master Aug 7, 2019
@jlengstorf
Copy link
Owner

Thanks so much!

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.

2 participants