Node Auth Tutorial (JWT) #13 - Logging Users in (part 1)

  Рет қаралды 53,767

Net Ninja

Net Ninja

Күн бұрын

Пікірлер: 72
@CAPS_AMERICA
@CAPS_AMERICA 3 жыл бұрын
This series is priceless! I've learned so many web dev things in Shawn's channel than anywhere else!
@bensonyeboah297
@bensonyeboah297 4 жыл бұрын
First....all right then gang!!!!!!!!!!! Love u shawn!
@jovannovakovic5975
@jovannovakovic5975 4 жыл бұрын
This is pure gold content. Thank you, Shawn!
@Anonymous-sq6eo
@Anonymous-sq6eo 3 жыл бұрын
I am really enjoying your videos man, the way you explain the topics make things really clear. Quality content!
@ekaterinanikiforova2342
@ekaterinanikiforova2342 4 жыл бұрын
That precious moment when I get another error, and then Shaun gets the same !!!
@gustavodias7003
@gustavodias7003 2 жыл бұрын
When we validate email and password, it's a good idea not to send separate messages like "incorrect email" and "incorrect password". Send "Incorrect email or password" to preserve user privacy. Because if we enter an existing email in the database with any password, we will easily know that you have an account on xv1d30s, for example haha.
@kamandanuwijaya8910
@kamandanuwijaya8910 Жыл бұрын
yes sir agree
@wildarena1088
@wildarena1088 4 жыл бұрын
Good work, Shawn! I wish you could do refresh token part also, thanks :)
@sukho-ac
@sukho-ac 3 жыл бұрын
The Explanation is very clear, the content is great, please more often upload a videos thank you so much for the vids 😆🙏
@eminaliyev4953
@eminaliyev4953 4 жыл бұрын
Great stuff, thanks. I am looking forward to end this playlist asap ❤️
@devKazuto
@devKazuto 4 жыл бұрын
I prefer checking if something is not set or unequal instead of the opposite. Like this: if(!user) { throw Error('incorrect email') } or your code as an example pastebin.com/A6muwDxj This way you don't have your complete code inside an if statement and makes it cleaner and much more legible.
@NetNinja
@NetNinja 4 жыл бұрын
To be honest I prefer this as well. In this case I just happened to do it the other way.
@kenechukwunwobodo3138
@kenechukwunwobodo3138 Жыл бұрын
Hello, why do I keep getting User.login is not a function. Please note that I have already created the static method in the model file.
@TechWithDnes
@TechWithDnes 4 жыл бұрын
I always want to comment on your video for NO REASON :D
@onoseogbidi3830
@onoseogbidi3830 10 ай бұрын
Thank you for another amazing video. I have a question. Is it possible to put the userschema.statics.login code directly inside the login controller instead of putting in the model. I tried it but it didn't work. So just want to know if it is possible?
@TechWithDnes
@TechWithDnes 4 жыл бұрын
Instead of creating static method on userSchema, can we do those task in our authController itself? When to use statics?
@codewithbishal895
@codewithbishal895 3 жыл бұрын
no
@JS-zm5se
@JS-zm5se 3 жыл бұрын
Yes. You can
@pxlloewe1481
@pxlloewe1481 3 жыл бұрын
Thank you for this briliant series! But can you tell me wich syntax code highlighting you are using in VS code? My highlighting looks a bit strange, some variables are just grey, etc.
@SeeKnowledge
@SeeKnowledge 4 жыл бұрын
How do we know like ( this is async and this sync method ) any idea please help
@TechWithDnes
@TechWithDnes 4 жыл бұрын
NOTE: Using arrow function on statics method doesn't work here because of this 😋
@sayansingha8474
@sayansingha8474 4 жыл бұрын
'this'
@arantebw
@arantebw 4 жыл бұрын
Yes, be mindful of arrow function and "this" combination.
@muhrizqiardi
@muhrizqiardi 3 жыл бұрын
THANK YOU!!! I was wondering why....
@nagame859
@nagame859 Жыл бұрын
Thank you so much!!
@aremukolhade6937
@aremukolhade6937 2 жыл бұрын
Why didn't I get redirect to the home page after signing up/login
@johnmoore4248
@johnmoore4248 2 жыл бұрын
What is the good thing about adding logic inside mongoose static method rather than inside controller?
@amritgopinath9540
@amritgopinath9540 4 жыл бұрын
Hey net Ninja Can you please make a tutorial on svelte native as I am really interested in svelte and svelte native
@emanmohamed4827
@emanmohamed4827 3 жыл бұрын
I want to ask a question .. by using views which let users signup ,login and see everything in the website , so that means we don't need "front end "technologies like react or something ? i have a problem with the concept of "templates" , i used react before to let user login ,signup , send web tokens pla pla ,but can't get the connection between backend and frontend yet ! btw thanks for this awesome tutorial ..
@ThatGuyAnonymous
@ThatGuyAnonymous 4 жыл бұрын
Hey Shaun, thanks for this amazing series. I owe most of the things I know to you. Quick question though: is it common for professional dev to just write for themselves large node starters with auth strategies, template routes, email confirmation, file upload... to just use for their new projects? any cons to that? In my current region, I found myself having to write all the code front to back including the design and it's a bit overwhelming. BTW I'm currently following your firebase series (fantastic), but I still love to keep the control nodejs gives for custom projects with complex business logic, any advice?
@damiangowala5681
@damiangowala5681 4 жыл бұрын
Would you consider your implementation production-ready? Have you used the approach of creating custom authentication in any of your work? Thanks Shawn!
@NetNinja
@NetNinja 4 жыл бұрын
It really depends on the project. There is more to authentication than I couldn't possibly create in a tutorial series (claims/roles, csrf, password reset etc). I like to teach enough of the theory & demonstrate the core priniciples so people can take it in their own direction afterwards.
@pooriapeyvand2461
@pooriapeyvand2461 4 жыл бұрын
keep going bro . you are awsome
@NetNinja
@NetNinja 4 жыл бұрын
Thank you so much 😀
@Anto-mi5pn
@Anto-mi5pn 3 жыл бұрын
Is there a way to send the jwt as a request header instead of a cookie?
@sujalshah8452
@sujalshah8452 Жыл бұрын
thanks for the playlist.
@codeinnode4490
@codeinnode4490 2 жыл бұрын
Done Great Tutorial :)
@shyamsundargoyal9251
@shyamsundargoyal9251 4 жыл бұрын
trying to understand how he types with his fingers crossed...
@davidk7212
@davidk7212 Жыл бұрын
For anybody bothered by the elements moving when error messages are inserted (it drove me crazy), use span tags instead of div tags for the error elements.
@askoldtsentseusti-1122
@askoldtsentseusti-1122 2 жыл бұрын
my webstorm doesn't see the login method in the authController, hellp
@satvikjha8932
@satvikjha8932 4 жыл бұрын
its not working i am getting an error that the fetch didnt got the source,any help?
@remishehzad5814
@remishehzad5814 4 жыл бұрын
Hi shaun, I really appreciate 🙏 you making these awsome tutorials. Im having problem comparing passwords, it always returns false. Someone on internet said it maybe due the password feild size in the db whicb I cant manage to change. Help me out please
@devkofi
@devkofi 4 жыл бұрын
i was having same problem had to do this in the pre save if(user.isModified("password")) { const salt = await bcrypt.genSalt(10); const hash = await bcrypt.hash(user.password, salt); user.password = hash; } hope it works
@remishehzad5814
@remishehzad5814 4 жыл бұрын
@@devkofi in my case I had to create a pass in lower case because url is case sensitive.
@OsamaAli-dr3mb
@OsamaAli-dr3mb 2 жыл бұрын
I tried to do the static method login but it gives me this error: " Property 'login_post' does not exist on type 'Model'. " . I am using typescript. can you give me any advice? @The Net Ninja
@OsamaAli-dr3mb
@OsamaAli-dr3mb 2 жыл бұрын
I solved the issue by adding the static method inside the schema like this: statics: { async login_post(email, password) { const user = await this.findOne({ email }); if (!user) { throw Error('Incorrect Email') } const auth = await bcrypt.compare(password + process.env.BCRYPT_PASSWORD, user.password); if (!auth) { throw Error('Incorrect Password'); } return user; } }
@TheHangoverer
@TheHangoverer 4 жыл бұрын
Shouldn't the client have it's own folder and the server have it's own folder?
@stephaniecrispin674
@stephaniecrispin674 Жыл бұрын
I don't know who you are personally but I wish I did. You are one of the best gifts God gave to mankind and I'm not exaggerating
@NetNinja
@NetNinja Жыл бұрын
Thanks Stephanie! :)
@m12652
@m12652 Жыл бұрын
Thank you very much 👍
@NetNinja
@NetNinja Жыл бұрын
You're very welcome! :)
@ahmedehab5448
@ahmedehab5448 3 жыл бұрын
when i was using this it always gets me null from the database so i changed it to User and it worked instantly !!
@arjobansingh1940
@arjobansingh1940 3 жыл бұрын
Make sure you are using, normal function with keyword function, in statics. Because this keyword points to That model only inside regular function, not inside arrow function. It is a concept in itself, using this keyword in functions. But yeah, make sure you are not using this keyword in arrow function.
@shohagkhan3677
@shohagkhan3677 4 жыл бұрын
Thanks for this very important tutorial. I have one request for you 👏. If you could make a tutorial on graphql react apollo client side, that would be great for us. I think you know that there is not so good tutorial on graphql client side for authentication, authorization, pagination, filtering, file upload. If possible, please keep my request...👏
@cherry-lp8yq
@cherry-lp8yq 4 жыл бұрын
there is no way for deploying a website on internet for free right?
@zeroRedRaptor231
@zeroRedRaptor231 4 жыл бұрын
Yes use heroku
@phanisai3722
@phanisai3722 4 жыл бұрын
Hello sir, I wish you could do python tutorials.
@satvikjha8932
@satvikjha8932 4 жыл бұрын
server is responding with 400 for the fetch request
@julianstorm7722
@julianstorm7722 4 жыл бұрын
It was the static method for me...I typed userSchema.static instead of userSchema.statics as I was following the docs of mongoose...
@askoldtsentseusti-1122
@askoldtsentseusti-1122 2 жыл бұрын
also the same problem, how you solved it?
@muhammadmaulanasyahrizal3048
@muhammadmaulanasyahrizal3048 2 жыл бұрын
@@julianstorm7722 thanks, it workes in my case
@martinp.617
@martinp.617 4 жыл бұрын
Salamat..,
@D0hG
@D0hG 4 жыл бұрын
final year students, anyone ? xD
@ridl27
@ridl27 4 жыл бұрын
ty.
@note-karlo
@note-karlo 4 жыл бұрын
🙅‍♂️🙋‍♂️
@benabidhoussem4720
@benabidhoussem4720 3 жыл бұрын
400 Bad request :( HELP
@encabsss
@encabsss 2 жыл бұрын
Remove the curly brace '{}' on User.login under authControllers > Login > inside the try. It should be 'User.login(email, password)' And that should work!
@askoldtsentseusti-1122
@askoldtsentseusti-1122 2 жыл бұрын
@@encabsss not working, error in fetch api
@yash_______105
@yash_______105 2 жыл бұрын
@@askoldtsentseusti-1122 hav u solved it
@askoldtsentseusti-1122
@askoldtsentseusti-1122 2 жыл бұрын
@@yash_______105 yes
@askoldtsentseusti-1122
@askoldtsentseusti-1122 2 жыл бұрын
@@yash_______105 i forgot to add await to res.json
Node Auth Tutorial (JWT) #14 - Logging Users in (part 2)
7:16
Node Auth Tutorial (JWT) #11 - New User Signup (part 1)
13:30
Net Ninja
Рет қаралды 68 М.
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
Node.js API Authentication With JWT
23:01
Traversy Media
Рет қаралды 559 М.
Learn Node.js & Express with Project in 2 Hours
1:42:53
Dipesh Malvia
Рет қаралды 606 М.
Session Vs JWT: The Differences You May Not Know!
7:00
ByteByteGo
Рет қаралды 314 М.
FastAPI JWT Tutorial | How to add User Authentication
20:27
Eric Roby
Рет қаралды 69 М.
Build Node.js User Authentication - Password Login
13:31
Web Dev Simplified
Рет қаралды 533 М.
Node Auth Tutorial (JWT) #15 - Protecting Routes
11:10
Net Ninja
Рет қаралды 59 М.
Managing User Roles - NodeJS Authorization
16:33
PedroTech
Рет қаралды 149 М.
Vite Crash Course | Faster Alternative To CRA
16:24
Traversy Media
Рет қаралды 221 М.