NestJs REST API with MongoDB #5 - Authorization, Protect Routes, Current User and more
Вставка
- Опубліковано 30 січ 2023
- Final Code:
github.com/ghulamabbas2/libra...
Complete In-Depth NestJs UDEMY Courses:
www.udemy.com/course/nestjs-b...
⚙️ Gadgets I use for Recording:
💻 Laptop - Macbook PRO M1 - 16/512
amzn.to/4eUqrSe
🎤 MIC - Samson Technologies Q2U USB/XLR Dynamic Microphone
amzn.to/3W9Z4wl
🖱️Mouse - Logitech G402 Gaming Mouse Hyperion Fury USB, Black
amzn.to/3RY4xUy
⌨️ Keyboard - Logitech K380 Multi-Device Bluetooth Keyboard
amzn.to/3RY4Fn0
🖥️ Monitor - UltraSharp 24-Inch Screen Led-Lit Monitor (U2419H)
amzn.to/4bxidN6
In this video, we will learn how we can protect our routes from unauthenticated users in our NestJS API. In my previous videos, I created a complete CRUD Library API.
In this video, we will continue with that project and create our JWT Strategy, protect the routes,, and also we will save the current user in the book that is created by user in simple few steps.
If you like this video make sure to subscribe and share, and stay tuned for more coding videos.
This is exactly what I am searching and you have explained it very well.
Thank you
Great course brother. Learning Nestjs for the first time and you nailed it! Thanks once again.
This is by far the best course I've ever came across. Thank you
Glad it was helpful!
Amazing work @Abbas. God bless
Bro,
This is exactly what is was searching.
JAZAK ALLAH.
Great work
Superb 🎉🎉🎉
great job ur videos tut helpful for me to doing uni project tyty
Glad I could help!
Thank you sir
I am having a problem when i send the token in header. Parameter "filter" to find() must be an object, got "648a3b0c5f8e038f7ed52ab9" (type string). I dont know how to fix
Why do we not saved the token in cookie?
How to implement a role-based authorization
great course bro, thanksss. it's more used the express or the nestjs ?
NestJS is built on top of Express.js
i got this ploblem
[Nest] 19392 - 01/22/2024, 5:06:53 PM ERROR [ExceptionsHandler] Cannot read properties of undefined (reading '_id')
TypeError: Cannot read properties of undefined (reading '_id')
can enyone help me out this issues please
I have the same issue, have you found a solution yet?
@@Savangex same here :(
the user is simply undefined
How about update and delete by check the user is owned the book
You can add if check and make sure the user is same. if(req.user._id != book.user) then throw the error.
how to implement logout functionality
This will be implemented on the frontend. We just need to clear the token.
@@codingwithabbas what if anyone copy the token use it to login so there might be a security problem
We store our token at safe place, like httpOnly cookies, that cannot be accessed from frontend,
@@codingwithabbas Can we send an httpOnly Cookie instead of returning the jwt when the user logs in or signs up. and if we can are there things we should change in the passport strategy? and want to say thank you for the great tutorial
do you have a course like small facebook app with some functionality as like, comment, notification...on udemy pros, I need for build project like that!
awuawodawd
Your tutorials are so long
I will try to make short but sometimes in-depth explanation is necessary.
Why do we not saved the token in cookie?