今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Verifying JSON Web Tokens
- [Instructor] So now that we have our JSON Web Token, we need to actually verify that it hasn't been tampered with. And the way we can do that is by using the JSON Web Token packages verify method. So we're going to say JWT.verify. We're going to pass the token as the first argument. The second argument is going to be our secret process.env.JWT Secret. And after that, we have our callback which is going to have to be asynchronous, you'll see why in just a minute. And the two arguments here are going to be an error, if one occurred and the decoded JSON object. All right, so that should be our user. So just like we've seen before. First thing we're going to do is check if there was an error, if there was an error, chances are that means that the token was not intact, right? It had been tampered with in some way or just wasn't valid anymore. So in that case, we'll return a response with a status of 401, meaning the user…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
What is user authentication?6 分钟 27 秒
-
(已锁定)
Basic project setup6 分钟 28 秒
-
(已锁定)
Building a login page8 分钟 54 秒
-
(已锁定)
Building a sign-up page4 分钟 36 秒
-
(已锁定)
Creating private React routes4 分钟 11 秒
-
JSON Web Token basics9 分钟 22 秒
-
(已锁定)
Adding a sign-up route to the server8 分钟 10 秒
-
(已锁定)
Generating JSON Web Tokens6 分钟 10 秒
-
(已锁定)
Adding a login route to the server6 分钟 59 秒
-
(已锁定)
Implementing JWTs on the front end7 分钟 36 秒
-
(已锁定)
Adding JWTs to sign-up page4 分钟 29 秒
-
(已锁定)
Adding JWTs to login page2 分钟 11 秒
-
(已锁定)
Adding an update user route6 分钟 22 秒
-
(已锁定)
Verifying JSON Web Tokens5 分钟 17 秒
-
(已锁定)
Adding JWTs to the user info page7 分钟 29 秒
-
(已锁定)
Adding logout functionality1 分钟 33 秒
-
-
-
-
-
-
-