Authorization in NodeJS

  Рет қаралды 28,879

Piyush Garg

Piyush Garg

Жыл бұрын

► Master NodeJS Playlist: • Master NodeJS
In this tutorial video, you will learn how to implement authorization in NodeJS
► Complete Full Stack Web Developer RoadMap 2023: • Complete Full Stack We...
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It allows developers to run JavaScript on the server side, creating server-side applications with JavaScript.
► My Website: www.piyushgarg.dev
My Gears
► My Girlfriend: amzn.to/3WD6FRp
► Apple MacBook Laptop: amzn.to/3WBJgQn
► Anker USB Hub: amzn.to/3GhZSr0
► Blue Yeti Microphone: amzn.to/3YKZ9FT
► External 27” Monitor: amzn.to/3Vp3xaO
► Logitech MK295 Wireless Keyboard and Mouse: amzn.to/3DuL1bB
► Seagate Expansion 1TB External HDD: amzn.to/3QMm5Q8
► Tripod: amzn.to/3S4OwK4
► Ring Light: amzn.to/3YLf8DR
Disclaimer: All the links above are affiliate links.
Social Links
► Twitter - / piyushgarg_dev
► LinkedIn - / piyushgarg195
Video Titles
Authorization in Nodejs
JWT Authentication in NodeJS
Authorization using JWT in NodeJS
Adding User Login to Your Node.js Application
Authentication in NodeJS
Tags
#nodejs #authentication #javascript #expressjs #mongodb #mernstack #developer #api #https #server #javascriptinhindi #webdevelopment #webapp #realtimeapp #serverside #nonblockingio #tech

Пікірлер: 52
@sourabhrajwade1061
@sourabhrajwade1061 4 күн бұрын
Hey Piyush, nice explanation. I would like to highlight that you are doing a boolean coercion on string (for authorizationHeaderValue), I would suggest against it. Cheer !
@weforyouweb1165
@weforyouweb1165 Жыл бұрын
Superb video 🎉
@thebishalpaul
@thebishalpaul 10 ай бұрын
expected more details as there were in earlier videos. For eg at 9:50 you've removed line no 7 but mentioning the reason for it would've been helpful.
@flopgameryt399
@flopgameryt399 3 ай бұрын
Can you provide me source code bcz my code not working after seeing this video 😢
@muhammad_haseeb_pk
@muhammad_haseeb_pk 21 күн бұрын
he removed that line because previous just a 30sec before he did the same thing thing in middleware where he was checking that condition so that why he removed that from the code .
@amansultanbaig7130
@amansultanbaig7130 4 ай бұрын
can you make playlist for microservices with node & kafka ?
@messi_codes
@messi_codes 10 ай бұрын
confusing !
@Solo_playz
@Solo_playz 2 ай бұрын
Rewatch the last video and then watch this again for 10 times your homework 😂
@Bcs-Mohtisham
@Bcs-Mohtisham 2 ай бұрын
Fir example there is an ecommerce store and there are users and admins , users can login but can't see dashboard, which means they are authenticated but not authorized to do some functionalities
@PubG-dl5eh
@PubG-dl5eh Жыл бұрын
Thanks sir, for uploading this video👍🔥
@flopgameryt399
@flopgameryt399 3 ай бұрын
Can you provide me source code
@newwasd
@newwasd Жыл бұрын
Hi Piyush, deployed azure api, done app registrations but req.headers.authorization underfined
@user-su7eh6yr7k
@user-su7eh6yr7k 4 ай бұрын
Amazing sir jee❤️👍
@RohitKumar-dy2gc
@RohitKumar-dy2gc 3 ай бұрын
nice and easy
@satyajeetraj2366
@satyajeetraj2366 Жыл бұрын
Hi Piyush, how can we know when we have to use return in request handler, with res.send or res.redirect
@Arvind__-wu6zv
@Arvind__-wu6zv Ай бұрын
when you have a front end application like react or even using an xml request in case of simple js and you send a req on a specific route on server and expect a response. And based on that response you want to redirect or just show user the whatever you requested for is done, in that case you do req.send from server. for example, you created a todo list and you make a request on a endpoint that saves your todo and in response send an object which contains details of todo and a message which you can now render in react or if you are using js, you display some message. On the other hand, lets say you want to login and you fill the details on frontend and make a request on an endpoint which checks for credentials, now if the details are correct, there's no point of sending an object in response, you can simply redirect to homepage from server using res.redirect('/home'). You should know that you can redirect either from backend or even from front end. For example, in login case if credentials are correct you can send an object in response that contains a message that logged in successfully, render it on alert on login page and then redirect to home page from frontend. Its up to you what you want to send from server.
@Star_Walker1
@Star_Walker1 5 ай бұрын
Your explanation is very good
@flopgameryt399
@flopgameryt399 3 ай бұрын
Can you provide me source code bcz my code not working after seeing this video 😢
@user-gz7qj3rq6w
@user-gz7qj3rq6w 2 ай бұрын
@@flopgameryt399 const { getUser } = require('../service/auth'); async function checkForAuthentication(req, res, next) { try { const tokenCookie = req.cookies?.token; req.user = null; if (!tokenCookie) return next(); const token = tokenCookie; const user = getUser(token); req.user = user; return next(); } catch (error) { console.error("Authentication error:", error); return res.status(500).json({ error: 'Internal Server Error' }); } } function restrictTo(roles = []) { return function(req, res, next) { try { if (!req.user) return res.redirect("/login"); console.log(req.user.email); console.log(roles); if (!roles.includes(req.user.role)) return res.end("Unauthorized"); return next(); } catch (error) { return res.status(500).json({ error: 'Internal Server Error' }); } } } module.exports = { restrictTo, checkForAuthentication, }
@niklausmikaelson7332
@niklausmikaelson7332 Ай бұрын
I am having one issue when i am hitting end point with postman getting token in header but when i am hitting that login url from html not getting header
@dev_vlog_7
@dev_vlog_7 4 ай бұрын
Helping bro... Nice one
@flopgameryt399
@flopgameryt399 3 ай бұрын
Can you provide me source code bcz my code not working after seeing this video 😢
@tarunjawla9463
@tarunjawla9463 3 ай бұрын
can you please add the gitub link for this project?
@ravikumawat757
@ravikumawat757 14 күн бұрын
Guru ji , Please give us sourcecode also to read code for revison. Because our practice code not enough clear to read.
@silentworldsound
@silentworldsound 4 ай бұрын
how to check the user is logged in or not in reactjs?
@ilikethemost
@ilikethemost 4 ай бұрын
check access token of user ,if access token is expired then check refresh token in db is that is expired or not available then user in logged out else if access token is available then he is logged in ...that's basic concept
@dipanshmalhotra564
@dipanshmalhotra564 Жыл бұрын
OP!
@karankewat3071
@karankewat3071 Жыл бұрын
Hey piyush, bro I'm struggling to complete the web RTC video call video . I am stuck at last . I know you have created s new video. But I want to complete this project it self . So can you please elaborate how to negotiate at the last after connecting.
@RajSingh-oi8nl
@RajSingh-oi8nl Жыл бұрын
i was also facing that issue but i have fixed now.
@n001sourabhmahto3
@n001sourabhmahto3 Жыл бұрын
26th video completed watching of this playlist thanks piyush bhaiya. can u provide us the code.
@flopgameryt399
@flopgameryt399 3 ай бұрын
Can you provide me source code
@sscsupporter2929
@sscsupporter2929 Ай бұрын
i am getting error at req.headers ["authorization"] it is saying at headers???
@sscsupporter2929
@sscsupporter2929 Ай бұрын
anyone say error about this block showing error at req.headers ["authorization"] function checkForAuthentication(req, res ,next) { const authorizationHeaderValue = req.headers["authorization"]; req.user= null; if ( !authorizationHeaderValue || !authorizationHeaderValue.startsWith("Bearer") ) return next(); const token = authorizationHeaderValue.split("Bearer ")[1]; const user = getUser(token); req.user=user; return next(); }
@hetjayeshbhaipatel1075
@hetjayeshbhaipatel1075 2 ай бұрын
bhai apka fullstack project ka link kaha milega?
@keybored7862
@keybored7862 3 ай бұрын
Bro please upload the source code.. we follow your code but many times we encounter bugs and takes a lot of time to de bug by going to different parts of the video.
@mannkawatkar2449
@mannkawatkar2449 3 ай бұрын
Why You used youtube-app-1 database to update the user collection?? because in this application you were using short-url database..
@eliteboyfun280
@eliteboyfun280 2 ай бұрын
Same problem brother have you found the solution that why he use youtubeapp1 database from nowhere and how can we impliment that in our code please help me brother
@Akash-nh8pc
@Akash-nh8pc 29 күн бұрын
where to get these videos code on github, any link?
@muhammad_haseeb_pk
@muhammad_haseeb_pk 21 күн бұрын
from previous video comment section
@muhammad_haseeb_pk
@muhammad_haseeb_pk 21 күн бұрын
in the playlist
@mma-dost
@mma-dost Жыл бұрын
bhaiya great projects kab aayega bhaiya aap project react ke saath banao aur react bhi samja dena aisa theek rhega
@sushantdwivedi4407
@sushantdwivedi4407 2 ай бұрын
No offence but i downloaded your whole playlist and finds to much difficulty after URL Shortner since you are just coding and all there is nothing explained why you use this and all
@haker_rank
@haker_rank 21 күн бұрын
Yes I feel same !..
@user-lw8bp4de3i
@user-lw8bp4de3i 3 ай бұрын
Provide the code link or source code please
@lovelymusic3549
@lovelymusic3549 Жыл бұрын
Sir we are waiting for react JS course?
@piyushgargdev
@piyushgargdev Жыл бұрын
Ayega Ayega, React bhi ayega
@sushantdwivedi4407
@sushantdwivedi4407 2 ай бұрын
and still i didn't able to understand anything about authorization and authentication at all. Btw great efforts some may understand the whole but i didn't understand the penny.
@sushantdwivedi4407
@sushantdwivedi4407 2 ай бұрын
Since you are busy in just coding your project and everything
@divyanshukumar8440
@divyanshukumar8440 20 күн бұрын
confused !!!!!
Creating Discord Bot in NodeJS
21:45
Piyush Garg
Рет қаралды 33 М.
What are Cookies in NodeJS?
30:35
Piyush Garg
Рет қаралды 44 М.
OMG😳 #tiktok #shorts #potapova_blog
00:58
Potapova_blog
Рет қаралды 3,7 МЛН
FOOLED THE GUARD🤢
00:54
INO
Рет қаралды 62 МЛН
когда повзрослела // EVA mash
00:40
EVA mash
Рет қаралды 1,8 МЛН
JWT Authentication in NodeJS
14:30
Piyush Garg
Рет қаралды 72 М.
Building Node.js Authentication from Scratch
39:09
Piyush Garg
Рет қаралды 113 М.
Getting Started with Express and NodeJS
11:28
Piyush Garg
Рет қаралды 51 М.
WebSocket in NodeJS | Socket.IO - Real Time Messaging
32:27
Piyush Garg
Рет қаралды 128 М.
OMG😳 #tiktok #shorts #potapova_blog
00:58
Potapova_blog
Рет қаралды 3,7 МЛН