-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Authentication tutorial #9179
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
Authentication tutorial #9179
Conversation
0d9e8dc to
c1db8eb
Compare
Added to expose to feedback
151d8a8 to
f612e04
Compare
amberleyromo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is looking pretty good! I would pull over some of the applicable details and links from this section. (Linking to the simple-auth site, the create-client-paths plugin, etc). We can remove that section from the overview page after that.
@shannonbux we'll need to rethink the content for this overview page once the content migration project is finished.
|
Hi, @amberleyromo. Thanks for the response. I am writing in the style of a tutorial, mainly based on the simple-auth example availabe in the gatsby repo, but simplifying the code a bit (less routes and css styling). Added a few more steps for more feedback. I added a section "Creating client-only routes" that can be expand to engulf more of the concepts presented in the current section avalaible in the page Building apps with Gatsby. If I understood correctly, that was the suggestion, right? |
|
Hey @ManoelLobo -- the idea is to migrate content (#8103). The content is being pulled from a page that's a top-level overview page.
(From the Guide Overview style guide). So I believe this content should be migrated over to this relevant doc, and once all relevant content is migrated out of that overview doc, it will be edited into a proper overview page. Let me know if this answers your question? @shannonbux if you have thoughts/want to chime in? |
|
Ok, @amberleyromo, thanks for the clarification! I noticed somethingthat may be causing confusion: there is a link under Guides section (Guides - Use cases with Gatsby (including apps) - Building a site with authentication) and another in Advanced Tutorials section (Advanced Tutorials - Making a site with user authentication). I started working on the latter, the tutorial one. Are these duplicates/should be merged/should have different contents? |
- PrivateRoutes component - Minor typos fixed
8532e96 to
948e06c
Compare
|
I finished what I call "first complete draft", the main bulk of the tutorial should be here. Waiting for feedback & suggestions! |
|
Hi @ManoelLobo -- I think my comment didn't get posted, sorry! I thought I replied to this:
Very valid point. I will leave this up to @shannonbux for her word on the architecture / whether these were intended to serve two different purposes, or are duplicative. Thanks for your continued work on this! |
25b2215 to
ddcd53c
Compare
Let me know if these don't reflect your original meaning! I just did some minor edits.
shannonbux
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ManoelLobo this looks great from a style perspective! Excellent work on formatting the code snippets 👍
One style change needed before we can merge this: h1 is reserved for the title, so change any h1 headers to h2.
As far as the difference between the tutorial and doc go, they both should be different. The authentication doc should just explain that authentication is possible, explain how it is possible, and show a very short example, then link to example sites, this tutorial, and more information about client-only routes.
Want to write that doc too?
- Corrected section headings - Cleaned code snippets
|
Hey, @shannonbux, thanks for the review! I changed the headers as you requested, and made small fixes that I found myself.
Sure! I should open a PR in the next hours. Should I ping you/mention any specific issue? |
- Checking if the window global exists befor using it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, one more request:
Add these example sites to the bottom of the tutorial under further reading:
- https://github.com/DSchau/gatsby-mail
- https://github.com/gatsbyjs/gatsby/tree/master/examples/simple-auth
- https://github.com/gatsbyjs/store.gatsbyjs.org
Next, @DSchau will give this a technical review!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. I left a few comments, most of them are mere nits rather than substantive!
I haven't seen the approach with PrivateRoute and the @reach/router Router component directly, but it seems to work fairly well.
I solved this problem with a custom Layout component that handles authentication (with React context), and whitelisted routes that don't require it, but I think both solutions work pretty well.
Thanks for the PR!
If you're interested, my approach is here:
|
|
||
| <nav> | ||
| <Link to="/">Home</Link> | ||
| {` `} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: but these spaces should probably just be removed. I think it's an artifact from prettier, but a hard line break should work here instead of spacing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, they are there on purpose. The minification process removes any whitespace preceeded by a newline, so all the links stay side by side (<a>...</a><a>...</a>), and end up rendering as one big word (HomeProfileLogout) - the links would work normally, but visually they wolud look like one.
I could solve this with styling (inline styles or change the global css file), but thought it could be more code than needed to explain the tutorial (or maybe I'm a lazy typist 😆 )
Opinions?
|
|
||
| <nav> | ||
| <Link to="/">Home</Link> | ||
| {` `} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here with the spaces!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
|
@shannonbux links added 👍 @DSchau thanks for the review! |
shannonbux
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome!
|
Holy buckets, @ManoelLobo — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! |
Regarding gatsbyjs#8103 Starting the authentication tutorial. (Misc/Making a site with user authentication*) Mostly setting intro and starting to work into content. cc @shannonbux
Regarding gatsbyjs#8103 Starting the authentication tutorial. (Misc/Making a site with user authentication*) Mostly setting intro and starting to work into content. cc @shannonbux
Regarding #8103
Starting the authentication tutorial. (Misc/Making a site with user authentication*)
Mostly setting intro and starting to work into content.
cc @shannonbux