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

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