From the course: React: Authentication
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Adding logout functionality - React.js Tutorial
From the course: React: Authentication
Adding logout functionality
- [Instructor] All right. So at this point, even though it's still quite a simple app, we have a fully functioning authentication flow that allows our users to both create a new account and log in if they have an existing account. However, there is one last thing we have left to implement and that is allowing users to actually log out of our site. Right? If we click on that button now, we still see this alert. Now with JWTs, the way that logging out is usually implemented is simply by deleting the JWT token that we have stored in local storage. So, the code here is actually going to be amazingly simple. What we're going to do is go back to our user info page and scroll down to our log-out function here. And, we're going to remove the code that's in there right now. And, we're simply going to say localstorage.removeItem ('token'). And underneath that, we're going to push the user back to the login page by…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
What is user authentication?6m 27s
-
(Locked)
Basic project setup6m 28s
-
(Locked)
Building a login page8m 54s
-
(Locked)
Building a sign-up page4m 36s
-
(Locked)
Creating private React routes4m 11s
-
JSON Web Token basics9m 22s
-
(Locked)
Adding a sign-up route to the server8m 10s
-
(Locked)
Generating JSON Web Tokens6m 10s
-
(Locked)
Adding a login route to the server6m 59s
-
(Locked)
Implementing JWTs on the front end7m 36s
-
(Locked)
Adding JWTs to sign-up page4m 29s
-
(Locked)
Adding JWTs to login page2m 11s
-
(Locked)
Adding an update user route6m 22s
-
(Locked)
Verifying JSON Web Tokens5m 17s
-
(Locked)
Adding JWTs to the user info page7m 29s
-
(Locked)
Adding logout functionality1m 33s
-
-
-
-
-
-
-