From the course: Node: Authentication
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Deserializing the logged in user from the database
From the course: Node: Authentication
Deserializing the logged in user from the database
- So we are in theory, log in now. The userID is stored in the session, but now we have to create middleware that DC realizes this user, by the given userID from the database; and for that, I head back into Visual Studio Code, in there, I open server, app-js; and if we scroll down already edit a comment to do comment where they should go. So here I have implemented middleware that restores the user from the database, if the userID is present. So I'll start with writing the middleware, so an app dot use, and it's asynchronous because we want to access the database, request, response and next; and we also need to use a service. As you see right now, the user service is not being loaded. If everything works right in your Visual Studio Code installation, you can, should not be able to do something like that. First I add if not request dot session, dot userID, return, next. So this means…
Contents
-
-
-
-
(Locked)
Registering new users13m 54s
-
(Locked)
Why plaintext passwords are bad3m 28s
-
(Locked)
Hashing and validating passwords with bcrypt7m 27s
-
(Locked)
Implementing login and logout10m 22s
-
(Locked)
Deserializing the logged in user from the database4m 49s
-
(Locked)
Offer remember me7m 13s
-
(Locked)
Require user verification10m 24s
-
(Locked)
Resetting passwords4m 1s
-
(Locked)
Implementing the password reset flow14m 1s
-
(Locked)
-
-
-