Тёмный

Implementing User Authentication With Node JS and PostgreSQL 

Conor Bailey
Подписаться 11 тыс.
Просмотров 118 тыс.
50% 1

Hi all,
In this video we are going to be building a Node JS application which will connect to Postgres (SQL) database. The database will be used to store user details including their names, email addresses and passwords in order for them to log on to the application.
We will be using the following Node libraries:
Express - To serve our application
bcrypt - To hash user password to make them secure
express-session - To store session details in a session cookie object
express-flash - To display flash messages to the user
passport - To authenticate users
passport-local - To implement a local authentication strategy for our application
I hope you enjoy the video. Please leave me a comment below if you have any questions.
Source code: github.com/conorbailey90/node...
Thanks guys. If you find this tutorial helpful then please consider subscribing to my channel.
Conor

Наука

Опубликовано:

 

31 мар 2020

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 242   
@LightningFox2407
@LightningFox2407 3 года назад
absolute legend - so many concepts explained very well and linked together all at once, thank you!
@ConorBailey
@ConorBailey 3 года назад
Glad it helped dude! :D
@Samsul2013
@Samsul2013 3 года назад
Hi Conor, it seems your video is the best without distracting me from other issues unrelated to auth in the lesson
@gregorvand4790
@gregorvand4790 3 года назад
Great tutorial - easy to follow along, and like some others have said, seeing the debugging is good and keeps knowledge fresh for the viewer. More of these!
@ConorBailey
@ConorBailey 3 года назад
Cheers Gregor! Glad it helped mate!
@knowledgemagnetic4518
@knowledgemagnetic4518 4 года назад
Great tutorial. Everything worked and I learned a lot in the process. Thanks!!!
@FlukeHusky
@FlukeHusky 3 года назад
This has been super helpful. Thank you so much for making this tutorial!!
@ConorBailey
@ConorBailey 3 года назад
Thank you Fluke. Glad it helped mate.
@MoonlightReserve
@MoonlightReserve 3 года назад
I rummaged through all RU-vid in search of a similar video, thank you very much, you helped me do my term paper.
@ConorBailey
@ConorBailey 3 года назад
Awesome mate! Thanks for watching and good luck with the rest of your course 👍
@raffayahmed9390
@raffayahmed9390 2 года назад
Perfect Explanation, I'll surely use this whole auth system in my projects !!
@nikitagupta8114
@nikitagupta8114 4 года назад
Thank you so much. The tutorial was so nicely explained and it is very helpful for beginners. Keep it up!
@seankennelly2984
@seankennelly2984 3 месяца назад
Excellent, really helpful and easy to follow! I'm glad you left some mistakes in the video as they gave a chance for me to check my code and find them myself
@amitabhxyz
@amitabhxyz 10 месяцев назад
Did the complete tutorial with you! Worked like a charm! Thank you for sharing this! :) Ahh quick edit: Since version 0.6.0 req.logout() function is asynchronous. So towards the end, for logout the code should be modified as follows: ``` app.get("/users/logout", (req,res) => { req.logOut(function(err) { if (err) { return next(err); } req.flash("success_msg", "You have successfully logged out."); res.redirect("/users/login"); }); }); ```
@sarajarjen
@sarajarjen 6 месяцев назад
Thank you so much ! 😀
@seankennelly2984
@seankennelly2984 3 месяца назад
I also had this issue and resolved it the same way!
@ShifaAfreenSiddiqui
@ShifaAfreenSiddiqui 3 месяца назад
​ Hey, I've been stuck at 51:24, where he creates a pool for querying data to see if the users are already registered. Where when he creates the call back function, all is working fine until i create the if condition wherein 'if the results.rows.lentgh>0) for some reason my application is crashing at run time throwing errors and I can't figure out how. Can you help me? I've been stuck at it all day...
@taylorgraham2906
@taylorgraham2906 4 года назад
Amazing video! I ended up needing to use react for my frontend but this was the best explanation ever. Definitely will watch more of yours! :)
@ConorBailey
@ConorBailey 4 года назад
Thanks for watching and for your comment Taylor. Glad it helps. 👍
@MasterPritex
@MasterPritex 4 года назад
Hi Taylor, i saw that you used react for the frontend, how have you managed to fetch the login token through the server api?
@taylorgraham2906
@taylorgraham2906 4 года назад
@@MasterPritex I ended up using a JSON web token instead of passport. It simplified the process quite a bit. Here is another helpful tutorial from Stoic: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-7UQBMb8ZpuE.html . I'd still love to see @Conor's take on how to do so :)
@jameswbsstudent7332
@jameswbsstudent7332 4 года назад
can u share taylor how you did the front end version of this or share your working github link for that and any set up instructions? thanks
@windubitably
@windubitably 3 года назад
I’m using React and JWTs, too, and I still found this video super helpful.
@andreygrigorev8366
@andreygrigorev8366 3 года назад
That video helped me so so much! Finally i can make auth at my website. You have no clue how i'm grateful to you, subbed.
@ConorBailey
@ConorBailey 3 года назад
Awesome! Glad it helped Andrey!
@olaman
@olaman Год назад
this was awesome! i was transalting your JS to TS. Challenging but worth it
@Samsul2013
@Samsul2013 3 года назад
The most brilliant instructor on earth
@riccardovitali3564
@riccardovitali3564 4 года назад
Great video, thank you very much, I love when you solve the issue, it's debugging!
@maheswaranparameswaran8532
@maheswaranparameswaran8532 3 года назад
Thanks a lot Conor for this tutorial, really helped me a lot for my Project!!!...Keep up the good work man
@ConorBailey
@ConorBailey 3 года назад
Thank you very much mate. Glad it helped!
@parfaitmombo7471
@parfaitmombo7471 3 года назад
Thanks, Conor! I appreciated the way you went step by step and mentioned what you will be doing in each step. It helps a lot to have a logical flow. Cheers! By the way, I also created a Donal Trump account as you did.
@ConorBailey
@ConorBailey 3 года назад
Haha nice. His was the first name that came to my head 😂
@xXBaad13Xx
@xXBaad13Xx 4 года назад
Thank you so much. This tutorial is amazing and really useful!
@ConorBailey
@ConorBailey 4 года назад
Diego Aguirre cheers Diego. Glad it helps! 👍
@piyaasok
@piyaasok 3 года назад
Great tutorial .Thanks! . This was exactly what i was looking for . Like to add a forgot password option to this.
@blackboxCS
@blackboxCS Год назад
i never comment but this was a great video even after 2 years. thank you.
@MasterPritex
@MasterPritex 4 года назад
Wow man, i saw literally every tutorial in the first page of youtube, but yours is on another level. Keep going pal!
@ConorBailey
@ConorBailey 4 года назад
Thanks mate. Glad it helped!
@MasterPritex
@MasterPritex 4 года назад
@@ConorBailey I have only one question, how do i connect the react frontend with the express api? I have tried using fetch on the app.post /login, but i don't know how to store the cookie on the client side.
@ConorBailey
@ConorBailey 4 года назад
Red Hood will look into this and get back to you mate.
@jameswbsstudent7332
@jameswbsstudent7332 4 года назад
@@ConorBailey @Red Hood hi i really have urgent need for the same, can you help please today or tomororw on front end...plus see comment above..thanks´so much
@FrankUnderwoood
@FrankUnderwoood 3 года назад
Thank you for this amazing tutorial man! It was super helpful for me.
@ConorBailey
@ConorBailey 3 года назад
Glad it helped you Frank! 👍
@mrexpert1854
@mrexpert1854 2 года назад
Thanks Sir... This was really helpful looking forward to more gr8 content from you....
@lyonserdar
@lyonserdar 3 года назад
Thanks for the great tutorial!
@pawelraszkiewicz565
@pawelraszkiewicz565 2 года назад
great tutorial! Really helped me grasp passport
@sanlaynx
@sanlaynx 3 года назад
thanks for the video, couldn't find such info about authorization
@marcocamparone3674
@marcocamparone3674 3 года назад
Great tutorial! Thanks from Arg!
@talhazaryab
@talhazaryab 3 года назад
They say that the Devil works hard. Everyone’s wrong. You work harder. This was the most needed tutorial for me. It helped me alot.
@ConorBailey
@ConorBailey 3 года назад
Thanks Tahla! So glad it helped you out!
@armer18
@armer18 4 года назад
49:13 - How to register users in DB with hashed passwords etc. 1:03:44 - How to login
@yarikks1862
@yarikks1862 3 года назад
thanks
@nmasichichukwuemeka5047
@nmasichichukwuemeka5047 3 года назад
thank you
@ShifaAfreenSiddiqui
@ShifaAfreenSiddiqui 3 месяца назад
​@@yarikks1862 Hey, I've been stuck at 51:24, where he creates a pool for querying data to see if the users are already registered. Where when he creates the call back function, all is working fine until i create the if condition wherein 'if the results.rows.lentgh>0) for some reason my application is crashing at run time throwing errors and I can't figure out how. Can you help me? I've been stuck at it all day...
@ebenezersiaw935
@ebenezersiaw935 4 года назад
Thanks a lot Conor Bailey. God bless you
@ihabelrayah7091
@ihabelrayah7091 Год назад
God bless him!!!!
@samshaker7945
@samshaker7945 3 года назад
Great tutorial! Thankyou Conor.
@ConorBailey
@ConorBailey 3 года назад
Glad it helped Sam. Thanks for watching bud 👍
@king998100
@king998100 4 года назад
appreciate your contribution! regards from M'sia.
@belmedia7326
@belmedia7326 3 года назад
Useful tutorial! Thank you!
@ConorBailey
@ConorBailey 3 года назад
Glad it was helpful!
@mykhailostepanishchev6472
@mykhailostepanishchev6472 3 года назад
Amazing, thank you.
@sarajarjen
@sarajarjen 6 месяцев назад
Great video, thank you ! :))
@yosimarzahidaquinososa5893
@yosimarzahidaquinososa5893 3 года назад
thanks for the video, you have helped me a lot
@kitestance
@kitestance Год назад
Thank you for showing the mistakes and errors. Good stuff.
@alexpeirson4278
@alexpeirson4278 3 года назад
Super clear and helpful tutorial, thank you :)
@ConorBailey
@ConorBailey 3 года назад
Nice one Alex
@not_shank
@not_shank 3 года назад
Excellent video....I was able to follow and understand the concepts very well... However, there is a security concern that the memory may leak by using express-session. A simple fix is to use cookie-session instead and continue as usual . I'd love to see more of such contents . Thank you :)
@ConorBailey
@ConorBailey 3 года назад
Hey Shashank! Thanks for watching bud. Appreciate the tip as well! Will look into cookie-session. Nice one!
@brahimhomri113
@brahimhomri113 2 года назад
Thank You So Much , Great Presentation
@harshavardhannakkina1843
@harshavardhannakkina1843 3 года назад
awesome, great video, thank you very much
@katanwillis
@katanwillis 3 года назад
Thank you . This is an Amazing Video. Your video is more clearly to understand bfor a beginner.
@ConorBailey
@ConorBailey 3 года назад
Thank you! Glad it helped!
@katanwillis
@katanwillis 3 года назад
Could you consider making other version using typescript and html ?
@fabricioalvarez3895
@fabricioalvarez3895 3 года назад
Thank you so much, you're amazing!!!
@daviesadedeji5344
@daviesadedeji5344 3 года назад
you are a Very good teach id recommend you any time. Great job. Also kindly take use more on ejs(cos im new to it), angular, and nestjs
@otepiii
@otepiii 4 года назад
awesome video! thanks a lot!
@raviprakashsingh9782
@raviprakashsingh9782 4 года назад
Amazing video and content, you really helped me out. Thanks
@ConorBailey
@ConorBailey 4 года назад
Ravi Prakash Singh n😊Nice one Ravi. Glad it helped mate! 👍
@didahandian6029
@didahandian6029 2 года назад
thank you for the tutorial its helpful for me
@rodgamwo
@rodgamwo 4 месяца назад
amazing. thanks a lot
@frederikdiamond
@frederikdiamond Год назад
Great video. I learned a lot 👍
@stevensong6909
@stevensong6909 4 года назад
I LIKE IT !
@thalleskaic
@thalleskaic 9 месяцев назад
thank you it really helped!!
@alesofton
@alesofton 4 года назад
good and perfect, thanks from chile
@vincenzoivanpanacciulli6377
thank you so much!
@itzblinkzy1728
@itzblinkzy1728 3 года назад
Great explanation, thank you :)
@ConorBailey
@ConorBailey 3 года назад
Itz Blinkzy thanks Itz! Glad it helped
@marcincylkowski3004
@marcincylkowski3004 4 года назад
Thanks for your video! It is amazing
@ConorBailey
@ConorBailey 4 года назад
Nice one Marcin 👍
@roghanbehm4639
@roghanbehm4639 Год назад
exactly what i needed, cheers
@hemparekh8839
@hemparekh8839 3 года назад
Amazing Video!!
@tamilpick7950
@tamilpick7950 Год назад
Thanks a lot ! It is really helpful 😇
@benjaminfisher3869
@benjaminfisher3869 Год назад
hi have you got this working? could you link your github repo, im stuck
@Sindoku
@Sindoku 3 года назад
Thanks, I have finally done my own secure authentication in JS thanks to you!
@ConorBailey
@ConorBailey 3 года назад
Nice one Brian. Glad it helped mate.
@Sindoku
@Sindoku 3 года назад
@@ConorBailey You don't know how long I've been trying to do proper server side authentication and authorization. I've done single refresh tokens before, but they are less secure than jwt with a refresh token. Now, that I know how to properly authenticate and authorize people, I can move on to the next phase of my idea for a website that sells services.
@RaefetOuafiqo
@RaefetOuafiqo 3 года назад
@@Sindoku is he using JWT ?
@jamieplunkett9669
@jamieplunkett9669 3 года назад
Thank you so much!! this is amazing stuff
@ConorBailey
@ConorBailey 3 года назад
Thanks Jamie. Glad it helped dude!
@mephesh
@mephesh 4 года назад
I followed the video coding all the way to the end and yes it just works. Learned everything about passport along the way, and ejs. Thank you Conor. Next step is to write some react pages that consume it as a api. I noticed the project does some specials with ejs/routing/redirecting so it will be interesting. Might have to remove the specials to have it work with react not sure, all up great vid. I do like that the project has ejs pages that can test everything, bit like a swagger. api time!
@shalinichahar6389
@shalinichahar6389 6 месяцев назад
hi please can you tell how did you connect react?
@RobrotoPlays
@RobrotoPlays 2 года назад
my savior + it''s on mac. :) TYSM
@Teach_Udemy
@Teach_Udemy 7 месяцев назад
Amazing vide
@luissalas4888
@luissalas4888 3 года назад
Thanks, you rock!
@hotaru6765
@hotaru6765 2 года назад
Thank you Sir
@hernanbritos1977
@hernanbritos1977 3 года назад
Nice video men!!! Loves from arg
@ConorBailey
@ConorBailey 3 года назад
Thanks mate!
@justindb83
@justindb83 4 года назад
Great video, very helpful!, would be cooler if this was split out to separate VS Projects, i.e. front end code, and back end code. EJS though... yuck. I guess this reminded me on why I use lit-html templates instead now :)
@vishalsrivastava4981
@vishalsrivastava4981 3 года назад
Amazing
@francot7717
@francot7717 3 года назад
Genius! liked, sucribed!
@ConorBailey
@ConorBailey 3 года назад
Thanks mate! Glad it helped.
@Hakeem-rk4ns
@Hakeem-rk4ns 4 года назад
Good job
@samkiernan8878
@samkiernan8878 2 года назад
Mate this shit is so good, you ever come to Norwich I will treat you so right ;)
@samkiernan8878
@samkiernan8878 2 года назад
litterally clapping right now mate, bravo!!!!
@tayyabmughal10000
@tayyabmughal10000 Год назад
Thanks for the github link...😘😘
@williamtrapp2857
@williamtrapp2857 3 года назад
Awesome video and link to the source code. I was able to work through getting my app up.
@ConorBailey
@ConorBailey 3 года назад
William Trapp nice one William!
@phrankadams7181
@phrankadams7181 8 месяцев назад
We didnt see the connection made between the app and the database,just the codes...but i really loved this video
@parminderkaur4136
@parminderkaur4136 3 года назад
this is the best video I ever saw. thank you very very much. Also can you upload video tutorials on how to make smart contracts in blockchain.
@ConorBailey
@ConorBailey 3 года назад
Hey thanks Parminder! Really glad you found this helpful. I don’t know much about blockchain to be honest. The best place to start would be this video an evolve from there: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-zVqczFZr124.html All the best. Conor
@yuvrajumale367
@yuvrajumale367 3 года назад
great thank you
@Royale3533
@Royale3533 4 года назад
Thanks!
@mohakgaur4603
@mohakgaur4603 8 месяцев назад
How do you add a semicolon at the end of the line while your cursor is not at the end, like is there any keyboard shortcuts or something...?
@alexm1126
@alexm1126 Год назад
hello, a small comment, the req logOut method now requires a callback function, I got the error until I found on the internet it now is asynchronous
@farawayofme2918
@farawayofme2918 7 месяцев назад
Great tutorial - thanks for simblicity.... if you dont mind how to make search engine with node.js and postgres
@Maik-wi2vy
@Maik-wi2vy 3 года назад
All in all a good video. But you could have mentioned that the default server-side session storage is purposely not designed for a production environment and that you should use a session store.
@luisalbertovillarortiz7424
@luisalbertovillarortiz7424 2 года назад
Thanks for sharing and teaching us It was a handy and neat way to blend/mix and use these useful skills! On the other hand I want to ask you how to continue typing after (END) IN MINUTE 4:49 .... thanks!! you have my like!!!
@pranav_arya
@pranav_arya 2 года назад
just press enter
@josemanuelsamanomijangos4936
@josemanuelsamanomijangos4936 2 года назад
Hi... I've been trying to implement your code by following each file you make step by step; unfortunately I'm stuck in the part where the req.body returns empty or undefined... any suggestions on how to fix it
@manuelbarinas5960
@manuelbarinas5960 4 года назад
great job! this is the most complete video i have seen on youtube. Is there a possibility to explain something similar using vue?
@samiayahia2879
@samiayahia2879 4 года назад
hey,i need a help ,can you help me please ?
@orlandoemilianogarciadiaz2531
@orlandoemilianogarciadiaz2531 2 года назад
Great video, buddy. But researching a few, I have just figured out that express-session will be deprecated soon for security troubles. In that case I recommend to use JWT, which encrypts the information during the session.
@alexwhitmore4902
@alexwhitmore4902 3 года назад
PLEASE HELP: at 4:04, what is the command you press to get out of the (END)?
@codingdaily4094
@codingdaily4094 4 года назад
How to send a message on error to the Front-End if we have a backend made with Vue ? Please help me I'm stuck
@atronstechnologies
@atronstechnologies 3 месяца назад
Nice Conor. But when i click register after feiling all fill the routing is load and don't finish and the data isnot insert to the database. what is the problem will be?
@rowlandwilliams9827
@rowlandwilliams9827 3 года назад
Hey Conor, This tutorial is really helpful, thank you. Cleared up a lot of things I was unclear about. I know lots of people have asked, but you mentioned in an earlier comment that you were working on a similar tutorial incorporating a react front-end. I was just wondering if you ever uploaded this? Now that I have a backend with authentication set-up I'm going to try connect it with react but would be great to see how you would approach it. Cheers, Rowland
@ConorBailey
@ConorBailey 3 года назад
Hi Rowland. Glad the tutorial helped. I do remember mentioning that but I just never got round to doing it. I haven't used React for a while now tbh but I will try to look into making a tutorial for this. Im sure there are packages available for handling flash messages and sessions with Passport in React.
@morningcoffeepoop
@morningcoffeepoop Год назад
I was following this video with React but somehow stuck at not having req.user (it's always undefined)...
@eldericomendoza1145
@eldericomendoza1145 2 года назад
Thanks, How can I call a PGpsql scrpt file (*sql) inside the node js without typing the while script? or pass the sql file inside the node js?
@wilsonquispe7568
@wilsonquispe7568 3 года назад
the best video !!!!!
@ConorBailey
@ConorBailey 3 года назад
Thanks Wilson!
@HUBTESLA
@HUBTESLA 3 года назад
Hello please help me. I have to use VUEJS, how do I do the server? I saw that you use ejs, but not me
@abhishekjyotishi4922
@abhishekjyotishi4922 2 года назад
I am unable to fetch data from db. The pool is not getting exported and the pool.query is not getting executed so unable to fetch data from db.Can you please help Conor Bailey
@jameswbsstudent7332
@jameswbsstudent7332 4 года назад
conor thanks for this great tutorial, it really is super good....can you also let us know how to take this and what would be need to transform this into REACT front end? i assume we are building this user registration here for admin users to the server app or would we use this for a client facing application as well or can we take the code and move stuff over to client side? ( have to do a login to my app for all users
@simaobonvalot7697
@simaobonvalot7697 Год назад
Is the passport library equivalent to the JWT ? I mean , do they have the same functionality ? Cheers mate , thanks for the video🙏
@mcaddit6802
@mcaddit6802 3 года назад
You have added 1 subscriber successfully!!
@ConorBailey
@ConorBailey 3 года назад
Thanks mate. Did you get this all sorted in the end?
@mcaddit6802
@mcaddit6802 3 года назад
@@ConorBailey Yes Bro.
@mcaddit6802
@mcaddit6802 3 года назад
Could you pls make a video on how to insert image to the database(PostgreSQL)
@maxzhukov5525
@maxzhukov5525 2 года назад
I did same but after insert in terminal I have this error: column "Conor" does not exist
@281
@281 2 года назад
How could I replace the ejs views files with React ones ?
@clementedonosok5434
@clementedonosok5434 3 года назад
Hi! How can I use reac for backend with this code? Can you explain me?
Далее
Building Node.js Authentication from Scratch
39:09
Просмотров 134 тыс.
Build restful API with PostgreSQL and Express
39:26
Просмотров 98 тыс.
JWT Authentication Tutorial - Node.js
27:36
Просмотров 1 млн
JWT Authentication using Node, Express & Postgres
1:43:12
Лучший браузер!
0:27
Просмотров 1,1 млн