From the course: React: Authentication
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Adding JWTs to sign-up and log-in pages - React.js Tutorial
From the course: React: Authentication
Adding JWTs to sign-up and log-in pages
- [Instructor] Alright, so now that we have the useToken and useUser custom hooks, let's integrate those into our pages, and we'll start off here with the login page and the signup page. Now, both of these pages are going to use the useToken custom hook because neither one of these pages is really going to need to care too much about the user, because they're not going to display the user or anything, right? Really all they need to know is whether the user is currently logged in, and when the user does log in, we're going to redirect the user to that user info page. So the user info page is what's going to use that useUser custom hook, but these ones are going to use useToken. So here's what this will look like. We'll start off by importing useToken. All right, there we go, and that didn't get imported for me automatically for some reason, but we'll just reference that like so. And the other thing that we're going to need here is we're going to need to import a library called axios…
Contents
- What is user authentication?6m 48s
- Basic project setup3m 20s
- (Locked)Creating private React routes8m 17s
- (Locked)JSON Web Token basics11m 29s
- (Locked)Solution: Working with JSON Web Tokens2m 43s
- (Locked)Adding a sign-up route to the server12m 20s
- (Locked)Generating JSON Web Tokens6m 9s
- (Locked)Adding a log-in route to the server4m 32s
- (Locked)Adding JWTs to the front-end4m 19s
- (Locked)Parsing JWT data4m 29s
- (Locked)Adding JWTs to sign-up and log-in pages5m 37s
- (Locked)Adding JWTs to the user info page9m 54s
- (Locked)Adding an "update user" route11m 47s
- (Locked)Adding update functionality to the front-end4m 49s
- (Locked)State management for tokens7m 18s
- (Locked)Adding log-out functionality3m 47s