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"); }); }); ```
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...
@@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...
@@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: ruclips.net/video/7UQBMb8ZpuE/видео.html . I'd still love to see @Conor's take on how to do so :)
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.
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 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 @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
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
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!
Thank you! As recomendation when you get the error of pending in the process (just like happend to me) it appears to be a problem with pg. You can use npm uninstall pg --save and then install it again with npm install pg --save. That solves the problem
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 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.
Hi, amazing video. When I cloned your source code on github, it didn't run register and login button in login and signup page. I didn't understand why not work it. Display result on the terminal screen, but does not open dashboard page, also doesn't save the change on the database. Please help me, thank you.
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!!!
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?
This is a great video. Thanks man. I just recommended this video for a friend I am stucked somewhere: around the 50th minute of the tutorial, where you did the validation check for "If the user already exists". I don't know what's wrong, I just keep getting error at that point. Here is what it says: C:\Users\DELL\Desktop\Workspace\auth\server.js:57 throw err ^ Error: connect ECONNREFUSED 127.0.0.1:5432 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1106:14)
Lateef Olayinka Quadri hi mate. Thank you for watching and for sharing. Much appreciated. It’s hard for me to say where that error is coming from without seeing the full code. Maybe this article will help: stackoverflow.com/questions/14168433/node-js-error-connect-econnrefused Let me know how you get on. Thanks again.
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.
Great video, but the express logout function has been updated and now requires a callback function. I included the redirect to login inside the 'req.logout(redirect in here)' and now it works. But overall, great video, super simpe to understand and easy to follow along.
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.
For anyone having an issue with req.logout(); It requires callback function so it is app.get("/users/logout", (req, res) => { req.logout(() => { req.flash('success_msg', 'You are logged out'); res.redirect("/users/login"); }); });
Hi Conor, Very good video, specially for beginners. I need to know how can we call postgres stored procedure, when i try it says object does not exist.
Hey Conor would you know why the querying is not working for me? I followed your tutorial exactly but when I click the register or login button, nothing happens...it just loads and the pool.query doesn't return or print anything in the console as well. I tested querying my database on a separate project and it works, but it's just not querying anything here.
It's okay I found the solution. I'll leave it here for anyone else who might be facing the same issue. It turns out that my pg module was version 7.x.x. I had to update the pg module to the latest version module which was version 8.5.1. Ran this line in the terminal and that fixed the problem. npm i pg@latest
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
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: ruclips.net/video/zVqczFZr124/видео.html All the best. Conor
@ConorBailey Thank you for a great tutorial. With a little more explanation on the lines of code the THEORY instead of those parts where you just coded in stuff, it would be perfect ..perhaps u could edit and add a recap to go through the final code walkthrough with theory? and also since many of us are using React Front End, how we can integrate this to the Front End? It is a little confusing the purpose on the back end only with Express and Postgres, instead of a React Express Postgres altogether. How would we change our code, how much can we keep, can all this be used as part of our front end user app? I have to figure that out by tomorrow, LOL. if you can help give some details on how to do this. Thanks. Also, 1) In general, when we download your finished app from github, and run npm install, then npm start, it still does not work, even when i change the .env file to my postgres setup.i..how do we get your app to work)
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 :)
interesting video its was very helpful ,Thank you so much .so do you have any video on how to save users details on the dashboard to the database like a form address or a biodata form been added and filled and saves on the database.
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
if anyone gets this error due to new passport version: req#logout requires a callback function, here is the fix for the logout endpoint app.get('/users/logout', function(req, res, next) { req.logout(function(err) { if (err) { return next(err); } req.flash('success_msg', "You have logged out."); res.redirect("/users/login"); }); })
It is a great video, thank you so much! I have one question - in an event, a user forgets his/her password, how can they retrieve it/reset their passcode?
R Ramana hi mate thanks for your comment. I’ll make a video on this soon. There will be some automated library available so will look into this and get back to you.
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
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.
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");
});
});
```
Thank you so much ! 😀
I also had this issue and resolved it the same way!
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...
try the condition, results.length>0, it will work@@ShifaAfreenSiddiqui
49:13 - How to register users in DB with hashed passwords etc.
1:03:44 - How to login
thanks
thank you
@@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...
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.
Thanks Tahla! So glad it helped you out!
absolute legend - so many concepts explained very well and linked together all at once, thank you!
Glad it helped dude! :D
This has been super helpful. Thank you so much for making this tutorial!!
Thank you Fluke. Glad it helped mate.
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! :)
Thanks for watching and for your comment Taylor. Glad it helps. 👍
Hi Taylor, i saw that you used react for the frontend, how have you managed to fetch the login token through the server api?
@@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: ruclips.net/video/7UQBMb8ZpuE/видео.html . I'd still love to see @Conor's take on how to do so :)
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
I’m using React and JWTs, too, and I still found this video super helpful.
Do you have a video on how to connect something like this to front end projects in HTML, CSS, JS? Thanks for the great vid!
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.
Haha nice. His was the first name that came to my head 😂
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!
Cheers Gregor! Glad it helped mate!
The most brilliant instructor on earth
I rummaged through all RUclips in search of a similar video, thank you very much, you helped me do my term paper.
Awesome mate! Thanks for watching and good luck with the rest of your course 👍
Watched the complete tutorial from Pakistan was really helpful
Wow man, i saw literally every tutorial in the first page of youtube, but yours is on another level. Keep going pal!
Thanks mate. Glad it helped!
@@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.
Red Hood will look into this and get back to you mate.
@@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
Hi Conor, it seems your video is the best without distracting me from other issues unrelated to auth in the lesson
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
i never comment but this was a great video even after 2 years. thank you.
Perfect Explanation, I'll surely use this whole auth system in my projects !!
Great tutorial. Everything worked and I learned a lot in the process. Thanks!!!
this was awesome! i was transalting your JS to TS. Challenging but worth it
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.
Awesome! Glad it helped Andrey!
Thank you . This is an Amazing Video. Your video is more clearly to understand bfor a beginner.
Thank you! Glad it helped!
Could you consider making other version
using typescript and html ?
Thank you for showing the mistakes and errors. Good stuff.
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!
hi please can you tell how did you connect react?
We didnt see the connection made between the app and the database,just the codes...but i really loved this video
Thank you!
As recomendation when you get the error of pending in the process (just like happend to me) it appears to be a problem with pg. You can use npm uninstall pg --save and then install it again with npm install pg --save. That solves the problem
This worked for me, thank you!
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 :)
Hey Shashank! Thanks for watching bud. Appreciate the tip as well! Will look into cookie-session. Nice one!
you can use word wrap toggled on to handle such long strings getting out of the window
Thanks Sir... This was really helpful looking forward to more gr8 content from you....
Coner…. Thank you for a great video and detailed explanation
Just out of curiosity, did you try to deploy it on Render ?
Mate this shit is so good, you ever come to Norwich I will treat you so right ;)
litterally clapping right now mate, bravo!!!!
Thanks, I have finally done my own secure authentication in JS thanks to you!
Nice one Brian. Glad it helped mate.
@@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.
@@Sindoku is he using JWT ?
Great tutorial .Thanks! . This was exactly what i was looking for . Like to add a forgot password option to this.
Great tutorial - thanks for simblicity.... if you dont mind how to make search engine with node.js and postgres
Hi, amazing video. When I cloned your source code on github, it didn't run register and login button in login and signup page. I didn't understand why not work it. Display result on the terminal screen, but does not open dashboard page, also doesn't save the change on the database. Please help me, thank you.
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
thanks for the video, couldn't find such info about authorization
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!!!
just press enter
Thanks a lot Conor for this tutorial, really helped me a lot for my Project!!!...Keep up the good work man
Thank you very much mate. Glad it helped!
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?
Thanks a lot Conor Bailey. God bless you
God bless him!!!!
Great tutorial! Thanks from Arg!
Great video, thank you very much, I love when you solve the issue, it's debugging!
Hi, My database does not work. Throw error, permission denied for table How can we fix this problem. Thank you.
This is a great video. Thanks man. I just recommended this video for a friend
I am stucked somewhere: around the 50th minute of the tutorial, where you did the validation check for "If the user already exists". I don't know what's wrong, I just keep getting error at that point. Here is what it says:
C:\Users\DELL\Desktop\Workspace\auth\server.js:57
throw err
^
Error: connect ECONNREFUSED 127.0.0.1:5432
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1106:14)
Lateef Olayinka Quadri hi mate. Thank you for watching and for sharing. Much appreciated. It’s hard for me to say where that error is coming from without seeing the full code. Maybe this article will help:
stackoverflow.com/questions/14168433/node-js-error-connect-econnrefused
Let me know how you get on. Thanks again.
@@ConorBailey Thank you!
I have solved it using try() and catch().
Another question that I have is that: is bcrypt enough to rely on for password hashing? Can one still use stuff like JWT?
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.
Great video, but the express logout function has been updated and now requires a callback function. I included the redirect to login inside the 'req.logout(redirect in here)' and now it works.
But overall, great video, super simpe to understand and easy to follow along.
How did you solve it can you explain me ???
@@ashishpurohit4352 app.get("/users/logout", (req, res) => {
req.logout(() => {
req.flash('success_msg', 'You are logged out');
res.redirect("/users/login");
});
});
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...?
Could you pls make a video on how to insert image to the database(PostgreSQL)
Useful tutorial! Thank you!
Glad it was helpful!
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.
great tutorial! Really helped me grasp passport
This video has all the information I wanted but somewhere the "why" is missing I think
Great tutorial! Thankyou Conor.
Glad it helped Sam. Thanks for watching bud 👍
For anyone having an issue with req.logout();
It requires callback function so it is
app.get("/users/logout", (req, res) => {
req.logout(() => {
req.flash('success_msg', 'You are logged out');
res.redirect("/users/login");
});
});
Hi Conor, Very good video, specially for beginners.
I need to know how can we call postgres stored procedure, when i try it says object does not exist.
Hallo! I have problem with command npm run dev. Already something on port. When I checked list of items on this port, it was empty😐
Have you tried using a different port number?
Thank you so much. This tutorial is amazing and really useful!
Diego Aguirre cheers Diego. Glad it helps! 👍
Thank you so much. The tutorial was so nicely explained and it is very helpful for beginners. Keep it up!
i am getting undefined these fields(name, email, password, password2) when i did console.log @ 40th minute
Same here... been trying to look at his source code to see if I've made any mistakes.
@@BarryThatcher you fixed it? im get an error too
does this work with .html files?
I did same but after insert in terminal I have this error: column "Conor" does not exist
Could you pls make video, in profile section user can insert,delete, update ad(selling)
Thank you for this amazing tutorial man! It was super helpful for me.
Glad it helped you Frank! 👍
Hey Conor would you know why the querying is not working for me? I followed your tutorial exactly but when I click the register or login button, nothing happens...it just loads and the pool.query doesn't return or print anything in the console as well. I tested querying my database on a separate project and it works, but it's just not querying anything here.
It's okay I found the solution. I'll leave it here for anyone else who might be facing the same issue. It turns out that my pg module was version 7.x.x. I had to update the pg module to the latest version module which was version 8.5.1. Ran this line in the terminal and that fixed the problem.
npm i pg@latest
appreciate your contribution! regards from M'sia.
Is the passport library equivalent to the JWT ? I mean , do they have the same functionality ?
Cheers mate , thanks for the video🙏
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
Hello the video is very instructive, can you explain to me how I can add another route next to the dashboard when I log in to put me on that route
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.
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: ruclips.net/video/zVqczFZr124/видео.html All the best. Conor
exactly what i needed, cheers
What if I'm using windows, none of the command prompt code works for me
@ConorBailey Thank you for a great tutorial. With a little more explanation on the lines of code the THEORY instead of those parts where you just coded in stuff, it would be perfect ..perhaps u could edit and add a recap to go through the final code walkthrough with theory? and also since many of us are using React Front End, how we can integrate this to the Front End? It is a little confusing the purpose on the back end only with Express and Postgres, instead of a React Express Postgres altogether. How would we change our code, how much can we keep, can all this be used as part of our front end user app? I have to figure that out by tomorrow, LOL. if you can help give some details on how to do this. Thanks. Also, 1) In general, when we download your finished app from github, and run npm install, then npm start, it still does not work, even when i change the .env file to my postgres setup.i..how do we get your app to work)
my register button isnt working im up to 40min and i followed every step any ideas?
Thank You So Much , Great Presentation
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 :)
Great video, thank you ! :))
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
thank you for the tutorial its helpful for me
Hi, I am actually using .html for my forms. I don’t use .ejs
Please, help me out with a guide
PLEASE HELP: at 4:04, what is the command you press to get out of the (END)?
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?
interesting video its was very helpful ,Thank you so much .so do you have any video on how to save users details on the dashboard to the database like a form address or a biodata form been added and filled and saves on the database.
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
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
if anyone gets this error due to new passport version: req#logout requires a callback function, here is the fix for the logout endpoint
app.get('/users/logout', function(req, res, next) {
req.logout(function(err) {
if (err) { return next(err); }
req.flash('success_msg', "You have logged out.");
res.redirect("/users/login");
});
})
Tysm brother
Thanks man. It`s really help me.
You have added 1 subscriber successfully!!
Thanks mate. Did you get this all sorted in the end?
@@ConorBailey Yes Bro.
Could you pls make a video on how to insert image to the database(PostgreSQL)
Super clear and helpful tutorial, thank you :)
Nice one Alex
Thanks for the great tutorial!
It is a great video, thank you so much! I have one question - in an event, a user forgets his/her password, how can they retrieve it/reset their passcode?
R Ramana hi mate thanks for your comment. I’ll make a video on this soon. There will be some automated library available so will look into this and get back to you.
thanks for the video, you have helped me a lot
Thanks a lot ! It is really helpful 😇
hi have you got this working? could you link your github repo, im stuck
awesome, great video, thank you very much
my savior + it''s on mac. :) TYSM
Hello please help me. I have to use VUEJS, how do I do the server? I saw that you use ejs, but not me
Great video. I learned a lot 👍
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
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.
Great explanation, thank you :)
Itz Blinkzy thanks Itz! Glad it helped
I love your videos. Can these ejs files be rendered on iphone with expo? How do i do that?
can make user login and admin login both in ecomers projects
Thanks for the github link...😘😘