- [Instructor] When it comes to serialization,…deserialization of users,…it's up to us to decide what to store in the session.…We could store the whole user object,…but this would also mean…that when a user is deleted or data is changed,…the stored user object in the session…would still be the same.…It's better to just store the user ID…and use this ID to retrieve the user from the database…for every time the session is loaded.…So, let's implement this serialization…and deserialization now.…
I will add…here, after line 19,…passport.serializeUser…and this function…gets the actual user as first argument…and the done callback.…And all we do here now is…we return…done…with null error,…but…a user._id.…
And we see that eslint is now complaining a bit here.…Here on line 21, it's telling us…that the block statement could be optimized.…So, let's let eslint just fix that.…So, I'm clicking into this line,…and do you see now this light bulb showing up?…And there I select Fix this arrow-body style problem.…And eslint will then…optimize that to a more shortcut syntax.…
Author
Released
2/7/2019- Creating a template engine
- Using MongoDB and Mongoose for user management
- Authenticating and authorizing users
- Adding cookies and sessions to Express
- Creating a login form with Passport
- Handling file uploads
- Storing and serving images
- Deploying an Express application
- Securing an Express application
- Running behind a web server
Skill Level Advanced
Duration
Views
Related Courses
-
Advanced Node.js
with Alex Banks2h 3m Advanced -
Advanced Node.js: Scaling Applications
with Alex Banks1h 15m Advanced
-
Introduction
-
What you should know1m 20s
-
Get your tools ready2m 1s
-
1. Know the Building Blocks and Internals of Express
-
Important Express middleware1m 27s
-
2. Use MongoDB and Mongoose to Manage Users
-
Connecting to MongoDB3m 27s
-
3. Authenticate and Authorize Users
-
Introduction to Passport1m 39s
-
Adding Passport to Express3m 55s
-
Providing a logout link2m 1s
-
Protecting routes3m 35s
-
4. Handle File Uploads and Process Images
-
File upload basics3m 9s
-
Serving images6m 32s
-
-
5. Deployment and Running in Production
-
Add logging5m 3s
-
Conclusion
-
Next steps44s
-
- 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.
CancelTake 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.
Share this video
Embed this video
Video: Serializing and deserializing users