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 a log-in route to the server - React.js Tutorial
From the course: React: Authentication
Adding a log-in route to the server
- [Instructor] All right, so now that we've created a signup route, let's do the same thing but with a login route. So the login route's going to look pretty similar to the signup route here. The main difference is that instead of creating the new user, like we did up here, we're just going to be loading that user out of the database and checking to make sure that their password is correct. So here's what this is going to look like. All right, we'll leave the signup route up at the top because that's the first part of the flow generally. So here's what this will look like. We'll say app.post, we're going to have this be a post route again, and the path for this is going to be /api/login. And then for the handler, we're going to say request and response. And we'll start off here by getting the email and password off the request body, just like in the signup route, all right? And the next thing we're going to do is we're going to load the user from the database. So all we need to do for…
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