Node.js With Passport Authentication | Full Project


In this video we will build a complete authentication app with login, register and access control using Node.js, Express, Passport, Mongoose and more.

Sponsor: DevMountain Bootcamp


💖 Become a Patron: Show support & get perks!

Website & Udemy Courses

Follow Traversy Media:

Patron Resources:
Carlos Mafla Channel –
ParkFlyer Explorer SEO –

Need Domains & Hosting?
Inmotion Hosting –
Namecheap –


Xem thêm bài viết khác:


  1. During the dependency install my facecam is in the way. The two it is covering is “passport-local” and “express-ejs-layouts”. Sorry about that

  2. If you get 'useNewUrlParser' deprecated grumbling in the console (at around 24:40 I think), just ignore it. As long as it still says MongoDB connected… at the bottom your good to go! And if you have connection issues, try double checking that your using your user password and NOT your login password, in the connection string. Noob thinking out loud. Hope it helps someone.

  3. Just up to 17:00 and ive had cpl of problems. I found the ejs module wasnt being included upon install, so had to install it separately. This being my first node js attempt, I was proud to discover how to navigate the various terminal commands to accomplish it!!! You now also have to sign up for fontawsome to get a CDN, but no biggie! Im finding understanding the concept of node js vs vanilla js tough to get my head around, but I'll get there with your help! Cheers buddy.

  4. I got another complaint using useNewUrlParser, so I put mongoose.set('useUnifiedTopology', true) above the cnx statement. Worked fine after that.

  5. Sir, when I am trying to register, data is not being saved in database in Atlas. And the page is being loading constantly. Please help. Do I need to create a database and do any configuration or it is created automatically?

  6. HTML comments does not work on EJS. JavaScript comments, on other hand: <% // 𝗂𝗇𝖼𝗅𝗎𝖽𝖾('./𝗉𝖺𝗋𝗍𝗂𝖺𝗅𝗌/𝗆𝖾𝗌𝗌𝖺𝗀𝖾𝗌.𝖾𝗃𝗌'); %>

  7. If anyone is still having problems with the mongoose connect, Login to Atlas, go to Database Access and click Edit on your user. Make a new password for your user using ONLY letters and numbers, and use that password in keys.js

    This worked for me:

    const db = require('./config/keys').MongoURI

    mongoose.connect(db, { useNewUrlParser: true, useUnifiedTopology: true })
    .then(() => console.log('MongoDB connected…'))
    .catch(err => console.log(err))

  8. hello, i am not getting the partial messages after inserting the include line in register.js

    when i inserted this line : <% include ./partials/messages.ejs %>
    i am getting the following error upon clicking the register button:
    SyntaxError: Unexpected token '/' in C:UserspandeDesktoptest4viewsregister.ejs while compiling ejs

    and i tried inserting this line as well: <%- include('./partials/messages.ejs'); %>

    now the syntax error is gone but i am not getting any partial messages.

    please help.

  9. npm i express bcryptjs passport passport-local ejs express-ejs-layouts mongoose connect-flash express-session

  10. Hii I am successfully able to implement this,but can somebody please explain me what if I have multiple pages like /shopping list, /myprofile so and how to implement this here we have auth.js in which we have isAuthorised bollean which return to next if user is logged out and or if false then user can open dashboard page.So how can I add more pages in this section??

  11. Hey brad, any strategies for reset password in node js? Would love to see a short tutorial on reset password functionality

  12. hai.. In this tutorial very useful and i got one error [TypeError: Cannot destructure property 'name' of 'req.body' as it is undefined.] in this error not clear so help me

  13. Thank you for your videos Brad! I really enjoy the extra tools you recommend like Bootswatch. Makes the project much more visually appealing, presentable and more portfolio ready. I also like how your older videos/projects build on top of each other. Much appreciated!

  14. I copied all files directly from the Github page and I get: errmsg: 'E11000 duplicate key error collection: test.users index: username_1 dup key: { username: null }',
    [Symbol(mongoErrorContextSymbol)]: {}
    Is this because I'm using my MongoDB account for another app that uses "username"?

  15. honestly this couldv been way better hadn't you spent time on the ui , couldv saved more than 20mins of tme

  16. This was by far the best online tutorial to create a login/logout system with NodeJS, Mongoose & Passport. ❤️
    PassportJS' documentation was so difficult to understand that I gave up trying to do this on my own. Thank you so much for this man! Much love! ❤️

    I just made a small change in my app – I used ejs instead of ejs-layouts as I was more familiar with the former.

    P.S.: Can you follow this video up with another video teaching us how to implement features like email ID verification, two-factor authentication, OAuth and Forgot Password? This would be a ready-to-deploy utility then!

  17. someone can help me? how can i make a validation for a 'admin' user? so when logged as admin, it redirect to /admin/dashboard for exemple, with special features

  18. Hello Brad, you never run the model to be saved in the database, how come when you go to collections and the data are prefilled.?

  19. hey brad just bought your course MERN stack..can you do a quick tutorial on logging in or sign up with google or FB..pleassseee…thanks

  20. at 24:00 you need this (because of newer MongoDB version):

    mongoose.connect(db, { useNewUrlParser: true, useUnifiedTopology: true })

    .then(() => console.log('MongoDB connected'))

    .catch(err => console.log(err));


Please enter your comment!
Please enter your name here