Тёмный

Learn JWT with the PERN stack by building a Registration/Login system Part 1 

Quacklearner
Подписаться 3,8 тыс.
Просмотров 74 тыс.
50% 1

In part one we build the restful API for our Registration / Login system
Video Time Stamps
0:00 - 3:43 Demo
3:43 - 16:21 What is JWT?
16:21 - 22:44 Code Preview
22:44 - 36:53 Create Server, Database, and Table
36:53 - 53:39 Build Register Route
53:39 - 59:24 Create JWT generator
59:24 - 1:06:53 Build Login Route
1:06:53 - 1:18:39 Create JWT middleware
1:18:39 - 1:30:47 Build Private Routes
1:30:47 - 1:33:49 Server Side Review
completed project : github.com/ousecTic/pern-jwt-...
postgresql installation: • PostgreSQL (Postgres) ...

Наука

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

 

5 авг 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 144   
@TheQuackLearner
@TheQuackLearner 4 года назад
Hey All, to prevent any future confusion, the git repository and the code in the tutorial are a tiny bit different but still work the same way. I provided comments for these two files to show you the difference. TL;DR => The payload for the JWT generator was different. jwtGenerator.js => github.com/l0609890/pern-jwt-tutorial/blob/master/server/utils/jwtGenerator.js dashboard.js => github.com/l0609890/pern-jwt-tutorial/blob/master/server/routes/dashboard.js I also notice that I used a post request when accessing our dashboard. This is not right! It should be a get request , because I am simply requesting information. Your application will still work;however I want to make sure you guys get the best practice so don't do what I did.
@harishnarasimhan6552
@harishnarasimhan6552 4 года назад
Hey, I think you missed out on typing the "next();" code after the line "req.user = payload.user;" in the authorization.js file at 1:12:24, if I'm not mistaken. Also, please come up with more tutorials for this stack as this is INSANELY helpful and understandable!! Great tutorial!!
@kackupa752
@kackupa752 4 года назад
@@harishnarasimhan6552 I have been trying to figure out what my problem was for quite a long time. Thank you for pointing this out!
@nikidhan
@nikidhan 3 года назад
i dont know which part i have to change to get request. router.post change to router.get?
@ravenhooper9263
@ravenhooper9263 Год назад
I got eveerything to work, it was the greatest feeling ever. Thanks!
@barrytophat
@barrytophat 3 года назад
Love the excitement of finding a course that deals with exactly what I need. I've created authentication with this stack before but this is going to be a good refresher
@elifdilaraaygun9502
@elifdilaraaygun9502 3 года назад
This is really a great approach to have a code review at the beginning, it makes it to be more understandable for sure. Thank you
@FedericoFavaro
@FedericoFavaro 3 года назад
Man, your tutorials are awesome. I knew a bit of express and a bit of react and stuff but didn't feel like I could actually build something with these technologies. Then I went through your to-do list and suddenly I realized that I have all the tools I need to be able to make a simple CRUD website, I just never knew how to put it all together. Your tutorials have literally unlocked me, I can now finally build websites for real!
@sunderlicious2746
@sunderlicious2746 10 месяцев назад
Thank you so much for simplifying and explain this! I have gone through many tutorials but after watching this, it all makes sense.
@nikolailchovski9909
@nikolailchovski9909 2 года назад
Perfect example of what I am trying to build with the same exact stack. Thank you very much for creating this video
@aithrajuniabouty599
@aithrajuniabouty599 3 года назад
i really really really love your tutorial videos because you always explain what the code does but doesn't make me overwhelmed. Thank you so much!!
@saziedhassan3976
@saziedhassan3976 3 года назад
Love how you explain each and every step so well man! If you do get the chance and build more complex applications with production level authentication and authorization, that would be amazing! Looking forward to more great content from you, subbed! :D
@tinpham6413
@tinpham6413 2 года назад
Thank you so much, you save me when I dive into the Backend with PERN stack, your tutorial is so practical and very easy to understand
@musthasinalam8769
@musthasinalam8769 4 года назад
Great tutorial! Really made jwt with PERN stack totally transparent to me. Thanks!
@trunojoyo84
@trunojoyo84 2 года назад
such an amazing teacher you are ! Please make another project on PERN stack. Will really help us beginner developers!
@vkray
@vkray 4 года назад
Great tutorial. I need more PERN tutorial like many to many relationship.
@tesfalemhaile8427
@tesfalemhaile8427 4 года назад
Henry, Such an amazing tutorial. The way you explain things is excellent. this is so great! thank you so much. not many programers have the ability to explain the way you did. I was looking such kind of programers, where have you been man! keep it up !!!!! 👌❤️.
@adiptabagas1803
@adiptabagas1803 Месяц назад
best pern stack tutorial out there without using an orm of course
@onigbindedavid6630
@onigbindedavid6630 21 день назад
That's why I chose to know this first instead of getting addicted to orm 😆
@alexkey9372
@alexkey9372 3 года назад
great tutorial! i tried prisma and it really simplifies all the sql queries if you are more familiar with json and mongodb.
@Inthedark72
@Inthedark72 4 года назад
Thank you for this tutorial, it was really helpful!
@brohogany9920
@brohogany9920 3 года назад
Thank you very much for posting these videos man.
@aditiranjan303
@aditiranjan303 2 года назад
henry your tutorials are awesome.....and very very helpful...pls make more of them
@jineshpatel007
@jineshpatel007 25 дней назад
Really appreciate your videos brother. Thank You So Much. Greetings from India
@JimmyCheng
@JimmyCheng 4 года назад
great content, best found so far, please keep it up!
@loganbramwell5209
@loganbramwell5209 Год назад
You are insanely talented at teaching
@eduardocarvalho4232
@eduardocarvalho4232 3 года назад
Very intuitive tutorial, greetings from Portugal :D
@rankokoturic6633
@rankokoturic6633 2 года назад
Great content, im new to backend development and this video really explains alot
@gavincoulson3900
@gavincoulson3900 3 года назад
Great stuff man, keep up the good work.
@blankname44
@blankname44 3 года назад
Thanks for the great tutorial bro. I subscribed for the high quality content :D
@kenobi6020
@kenobi6020 3 года назад
Really appreciate your work. All the content everywhere related to authentication is using the MERN stack, I just found this video in the comment section of another video explaining how to do authentication with postgres and express but no react :/ but luckily I ended up here. Thanks a lot! Gonna enjoy this as well as the rest of your videos so I can really master the PERN stack!
@55BLOCKS
@55BLOCKS 6 месяцев назад
Good job and I like your explanation simple and clear
@lolashepota4050
@lolashepota4050 2 года назад
Perfect tutirial! Well done!
@wanyi8761
@wanyi8761 3 года назад
for real this is a gem🥳 what a video thank you brother
@panos7853
@panos7853 4 года назад
Thanks a lot.Nice explanation too!Keep it up!! You earned a sub
@luisantonioloustaunaubauti7312
@luisantonioloustaunaubauti7312 3 года назад
Amazing tutorial. I got stuck at 1:12:46 when you created the authorization middleware. I believe there should be a next() at the bottom so the function continues to run. Once that was fixed it worked fine.
@lotusea7964
@lotusea7964 3 года назад
yup that's true
@modavikllc9705
@modavikllc9705 2 года назад
Just out of curiosity, just so i can understand this better.. why did it work for Henry during the tutorial w/out next() but not for me/us?
@deadlex3711
@deadlex3711 2 года назад
@@modavikllc9705 At 1:21:33, or so, you can see it gets added before he runs the get request
@modavikllc9705
@modavikllc9705 2 года назад
@@deadlex3711 ooh yeah i see.. that is one of the formatters he is using?
@maj22448
@maj22448 2 года назад
Please where put next () I'm new
@santinomantineo5275
@santinomantineo5275 9 месяцев назад
You sir just saved my life!
@SuperVladikk
@SuperVladikk 3 года назад
I want to say thank you and you the master!
@zoltancaputo9562
@zoltancaputo9562 10 месяцев назад
Amazing explantion! Tks
@parfaitmombo7471
@parfaitmombo7471 3 года назад
Thanks, bro! Nice tutorial.
@ankush1880
@ankush1880 3 года назад
Great content, thank you so much 🙂
@rishrauz3469
@rishrauz3469 Год назад
great video dude, thankyou
@sadidarhamar4393
@sadidarhamar4393 3 года назад
thank you bro , i expect more content from you :)
@eddiechen6389
@eddiechen6389 3 года назад
very well explained!
@abirkolin4702
@abirkolin4702 2 месяца назад
thanks a lot. learned so muchhh!!!
@Yaanzz1551
@Yaanzz1551 4 года назад
Really helpfull tutorial, it has way to little thumbs up. Everything works perfect.
@shaheerzaman620
@shaheerzaman620 4 года назад
Enjoyed it.Please do bigger series and go deeper. Like implementing many to many relationship etc.
@ignob9591
@ignob9591 4 года назад
I think a blogging website on PERN stack might help us to learn alot.
@rizkymahendra5732
@rizkymahendra5732 3 года назад
You save my homework, thanks!
@ericcartman4799
@ericcartman4799 3 года назад
great tutorial, thanks for that
@kurniamassidik5798
@kurniamassidik5798 Год назад
its been 2 years, but i really thanks bout your content
@jacosh3924
@jacosh3924 2 года назад
Really nice guide man
@MichaelOReillySD
@MichaelOReillySD Год назад
Wrist bellies... lol belly bands? Love the video and the laughs along the way
@lenglain
@lenglain 4 года назад
Wow this is awesome! Thanks for the good explanation of each step. I do have a minor complaint: Many tutorials assume that the viewer is too "dumb" to follow more intermediate use-cases and I think this is really unhelpful. If you do know how to incorporate this into a context/state management library and have the time to show that, that would be infinitely more instructive. These are videos after all and we can take as long as we want to understand each step. It would have also been great to see how this works with the exisint todo app you made (like how do you store todos by user? How do you load the correct user's todos once authenticated?) There are many scattered tutorials that show bits and pieces of how these things work but too few show how they all fit together. Almost none actually when it comes to this stack.
@TheQuackLearner
@TheQuackLearner 4 года назад
This is amazing! I typically don't get to see much feedback and idea when teaching so I appreciate you taking the time for giving me a new perspective. Thanks again for the good feedback and idea, I will keep them in mind.
@stealtime
@stealtime 3 года назад
yes. I totally agree on the point of combining this with the todo app. This is exactly what I would like to do -- be able to login and store each user's todos! does anyone have any tips on how to do this or know of any tutorials that show how to implement this?
@maximbazadji4895
@maximbazadji4895 4 года назад
Thanks a lot, Henry! Can u please make a video about https/cors, Redis, or microservices?
@MusicMan121
@MusicMan121 4 года назад
Hello. I read everywhere that the JWT should never be stored in local storage, but in cookies instead. May I ask you why you decided to store it in local storage?
@creatorsremose
@creatorsremose 2 года назад
Me: "Why is this guy's machine so damn slow?!" Video: 43:07 Me: "Oh, nevermind"
@user-ob2ev4yl8k
@user-ob2ev4yl8k 2 года назад
Quality content
@fathantn
@fathantn 2 года назад
Thank u sir for ur help
@m2tdev
@m2tdev 3 года назад
exactly what i wanted
@kiattisakphanphu3823
@kiattisakphanphu3823 4 года назад
thank you sir
@joebidenmytime
@joebidenmytime 3 года назад
Thanks for making this! Very helpful and interesting. Why in the authorize middleware do you set the payload.user to the req.user? Shouldn't they be the same if they are authorized? Also, VSC yelled a lot about both req and payload not containing a user property but I'm like converting this to typescript so that error is a little bit out of the scope of this video
@leanprogrammer
@leanprogrammer 2 года назад
Great stuff.. Looking forward to learn postgresql.. Ps: Never store jwt in localstorage... Save it in a cookie instead..
@alokp3357
@alokp3357 4 года назад
Very Helpful tutorial, could you please make a tutorial covering S3 redux and postgresql?
@badcode8029
@badcode8029 3 года назад
Thanks this is nice tutorial in the internet, the way you explain complicated things more easier to me. I think your pc lagging because your antivirus. haha
@JoshCodesIRL
@JoshCodesIRL 3 года назад
Hey! Going through the tutorial and trying to use postman on the register route at 44:31 and I'm getting the following error: Error: connect ECONNREFUSED 127.0.0.1:5000 Request Headers Content-Type: application/json User-Agent: PostmanRuntime/7.26.10 Accept: */* Host: localhost:5000 Accept-Encoding: gzip, deflate, br Connection: keep-alive it's also got a note that says it might be missing required headers? Any tips?
@inesborges4857
@inesborges4857 3 года назад
My route is not working at 44:31 when I try to make a post request. When I open localhost:5000 on browser it says cannot get /. How can I solve this problem?
@juiceontheloose123
@juiceontheloose123 2 года назад
thanks!!!!
@lotusea7964
@lotusea7964 3 года назад
thank you thank you thank you
@codr6934
@codr6934 4 года назад
Cool video! Can you say what the main processes are to secure the login and registration like from sql injections?
@Jonas-qm7ls
@Jonas-qm7ls 3 года назад
When I attempt to post correct token string as the token header nothing happens. However, when I input wrong or empty string as a token, it works. What am I doing wrong?
@brade.silver9852
@brade.silver9852 2 года назад
52:18 still getting a Server Error in POSTMAN and in my terminal am getting an ERROR saying null value in column "user_name" of relation "users" violates not-null constraint How is it working for him when he has created tables with a Not Null Constraints?
@rajdeeppurkayastha3287
@rajdeeppurkayastha3287 3 года назад
Please make more content on this stack
@aniketroy2656
@aniketroy2656 2 года назад
I get this error in console : Failed to load resource: the server responded with a status of 401 (Unauthorized) when loading any page. in post man when I tried doing 44:51, I got 404 not found. P.S. i zip downloaded the entire project and installed dependencies (by following beginning part of video) along with creating table and db in my PostgreSQL. Can anyone help ?
@codr6934
@codr6934 4 года назад
why do we need a jwt token at the registration if it works only 1 hr?
@shambhaviaggarwal9977
@shambhaviaggarwal9977 3 года назад
I did not get the twotwo reference at 44:17. What was that?
@saadahmad1848
@saadahmad1848 2 года назад
My dashboard says status 200, but doesn't print anything ( res.json), what should I do?
@brotskyCode
@brotskyCode 3 года назад
you are good speker, i am from Ukraine and understand all what you say
@didymusorotayo7883
@didymusorotayo7883 3 года назад
Thanks for this tutorial man. And you are a really good teacher but quick quest can I understand what this does "(![name, email, password].every(Boolean))" I understand every runs through the array and returns true if all conditions are met, what is the Boolean in the every method, is it some sort of callback that is behind the scene?
@lif5558
@lif5558 11 месяцев назад
everything is the same with yours until 1.18.39. when I add authorization, it always throw an error such as "email or psw is incorrect". what's wrong with my code?but I do the same things with you? I didn't get what's wrong. but thanks, you explain very well and clearful. I'm thankful to you.
@tima8625
@tima8625 4 года назад
Hi, I'm not sure why, but I am getting an error "data and salt arguments required" for following the steps up until 52:20 . When I console.log(password) it comes back undefined so the issue is with passing the password from the client side but I don't know how to fix this error. I'd appreciate any advice and help! Thanks.
@jamied6835
@jamied6835 2 года назад
Have you resolved this? I’m stuck here too.
@sarangcheruvattil5762
@sarangcheruvattil5762 3 года назад
How do you writing query in different lines instead of writing in one line..?
@muhammadhatifmujahid7832
@muhammadhatifmujahid7832 Год назад
hey everyone, my req.user is returning as undefined in dashboard.js does anyone have a fix for that?
@Youngtimmyy
@Youngtimmyy 3 года назад
does anybody know how setup postman because I keep trying to test mine on postman but it is not working
@joshxone
@joshxone 3 года назад
Not generating the JWT token for some reason. Can anyone help?
@sagarjain4128
@sagarjain4128 2 года назад
What's inside user_id ? At timing 19.19, line number 31?
@jusuftopic4204
@jusuftopic4204 3 года назад
Hallo. Thank you so much for tutorial. I have one problem. 48:05 When i want to check if user exist, I got this error : Cannot read property 'length' of undefined
@gearoidfly
@gearoidfly 2 года назад
Hi Henry, thank you for the great tutorial, I had a problem ( my doing, your video is flawless) I deleted my table, now my page doesn't work, I'm getting jwt expired and invalid syntax for type uuid: "register", any ideas? thanks in advance, keep up the great work.
@amarnathlaishram2835
@amarnathlaishram2835 2 года назад
Why my length says cannot read length of undefined
@ignob9591
@ignob9591 4 года назад
Hey Bro! Iam getting an error while installing bcrypt error:" bcrypt@4.0.1 install: `node-pre-gyp install --fallback-to-build`" please let me know where I made the mistake or solution for this error.
@ignob9591
@ignob9591 4 года назад
Hey Iam using "npm install bcryptjs" instead of " npm install bcrypt" because somewhere I read like both of them do samething.
@patrickkaipainen3301
@patrickkaipainen3301 3 года назад
Does he cover refresh tokens?
@roselpadilla
@roselpadilla 3 года назад
Thoughts on REPN vs PERN? "REP N" like nginx
@hassanxelamin
@hassanxelamin 2 года назад
if your middleware requests are stuck in a loop on postman, just remember to execute the next(); function so it knows to move on
@kennethz1539
@kennethz1539 3 года назад
Hi Henry, for the authorization.js, when I console.log verify, it is an object {iat:343423423, exp:23423432} . How can you set req.user = verify.user since verify does not has a "user" key. Later on for dashboard.js I couldn't access the user_Id, since the authorize doesn't get back the user_id~ please help thank you
@kennethz1539
@kennethz1539 3 года назад
oh gosh, just didn't pass the correct user_id to the jwtGenerator..thanks for you tutorial...
@alexwhitmore4902
@alexwhitmore4902 3 года назад
Hmm, when generating a JWT token I am getting a Server Error after doing, res.json({ token }) however, the new user is still added. Does anyone know why I'd get a error returned as opposed to the token returned? I've been following along exactly, I think.
@sethbridges3348
@sethbridges3348 3 года назад
Make sure your .env file is inside the server folder and not any other folder.
@atishpanday1800
@atishpanday1800 3 года назад
Hey, I loved your tutorial, and if you see this, I have a suggestion for you. Please please please, reduce the size of your integrated terminal so that we can see more of the code at once. Half your screen is occupied by the terminal for no reason. It's much easier to follow along when we can see more lines of code at once. Other than that, great explanation. Thanks!
@mer2550
@mer2550 3 года назад
validinfo status missing should be 400 bad gateway for clean. thank you for making tutorials
@user-wp1gh5sy3g
@user-wp1gh5sy3g Год назад
Hello I have a question regarding this code, are you still active and do you mind clarifying some questions that I have ?
@jairuscalvin9769
@jairuscalvin9769 2 года назад
Wow so helpful. can i have a questions? I got stuck in dashboard.js. Why on my dashboard cannot response user_id but the status is still 200 omg help me.
@SuperMBARutgers2013
@SuperMBARutgers2013 Год назад
"In the client section, it's not too complicated you'll figure it out" then proceeds to chuckle. 🤔🤭
@shivanshusharma6918
@shivanshusharma6918 3 года назад
Why you didn't use sequelize?
@opensourcerror
@opensourcerror 4 года назад
const {Pool} = require('pg') is shorter :)
@ignob9591
@ignob9591 4 года назад
cool!! you are right. Just now tried it in db.js
@farsikogama6114
@farsikogama6114 3 года назад
It is a shorthand which for beginner they might find it hard to understand
@jacobspade739
@jacobspade739 3 года назад
For some reason the jwtToken variable is 'undefined' after this part 'const jwtToken = req.header("token")'. Is anyone else having this problem? The request header is undefined
@maj22448
@maj22448 2 года назад
Me. Do you solve problem?
@kaseabernathy3642
@kaseabernathy3642 2 года назад
How many other people came here after a full stack todo tutorial?
@vithikabhatt6193
@vithikabhatt6193 Год назад
Hey I'm getting an error while running psql -U postgres
@vithikabhatt6193
@vithikabhatt6193 Год назад
Can anyone help me with this error 'psql' is not recognized as an internal or external command, operable program or batch file.
@blue_0146
@blue_0146 3 года назад
Cannot set headers after they are sent to the client, someone with this error????
@vryks5385
@vryks5385 3 года назад
I know this is a bit late, but incase you never got it or for anyone new to the video in future who also runs into this problem, just delete the two uses of res.json(newUser.rows[0]); as they are not needed. If youre really stuck, youll find that there is an updated code version on hit git (link in the description) that you can compare your code to.
@blue_0146
@blue_0146 3 года назад
@@vryks5385 yeah, that was The answer, i really thanks your response, better later than never, thanks to this tutorial i didn't fail The class, thank you very much
Далее
What Is JWT and Why Should You Use JWT
14:53
Просмотров 1,1 млн
ТЫ С ДРУГОМ В ДЕТСТВЕ😂#shorts
01:00
tRPC, gRPC, GraphQL or REST: when to use what?
10:46
Просмотров 76 тыс.
Auth Does NOT Have To Be Hard
17:13
Просмотров 97 тыс.
How to Deploy a PERN application on Heroku
43:50
Просмотров 32 тыс.
КАКОЙ SAMSUNG КУПИТЬ В 2024 ГОДУ
14:59
Это iPhone 16
0:52
Просмотров 630 тыс.
КРУТОЙ ТЕЛЕФОН
0:16
Просмотров 7 млн