In this exercise, you must implement the getFreshUser and verifyUser Methods in the auth module. You must also implement a sign-in method that generates a token to be sent back to the client.
(funky music)…- So what you all are going to be doing,…you've got three functions that we build out,…one's partially built,…two, not really.…The two are not built out at all.…But this one is the decodeToken.…So this is going to be a middleware that we're going to use…when we want to check the incoming requests token.…And its job is to do exactly what it says,…it's to decode the token,…it's to take the token with the secret,…turn it back to the way it was originally,…or at least attempts to.…
And if it can't, it should let us know,…so we can send an error back.…So I'll walk through what's happening here.…You can read the comments.…But in short, remember I was saying earlier,…the token should be on the authorization header,…but optionally it could also be on the query string.…This is what this check is doing,…it's like, "Okay, if we have req.query,…"and req.query has an access token property,…"they probably put the token on there.…"So let's grab the token off of that,…"and let's attach it to req.headers.authorization."…
This course was created by Frontend Masters. It was originally released on 12/30/2015. We're pleased to host this training in our library.
- Executing Node.js
- Using Express
- What is middleware?
- Testing in Node.js
- Using Mongo with Node.js
- Data modeling
- Querying data with Mongoose
- Identifying sensitive routes
- Configuring the deployment
Skill Level Intermediate
Node.js: Build Your First Microservicewith Daniel Khan2h 9m Intermediate
Building APIs Using Hapi in Node.jswith Kirsten Hunter2h 23m Intermediate
2. REST APIs
5. Organization and Configuration
7. Data Modeling
10. Securing Routes
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.