Authorization in NodeJS

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 พ.ย. 2024

ความคิดเห็น • 72

  • @thebishalpaul
    @thebishalpaul ปีที่แล้ว +7

    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 8 หลายเดือนก่อน +1

      Can you provide me source code bcz my code not working after seeing this video 😢

    • @muhammad_haseeb_pk
      @muhammad_haseeb_pk 5 หลายเดือนก่อน

      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 .

    • @Fe-ironman
      @Fe-ironman หลายเดือนก่อน

      i mean if u have watched earlier videos then you need to be able to understand that much

  • @dhruvsolanki4473
    @dhruvsolanki4473 3 หลายเดือนก่อน +1

    Amazing, able to understand everything very well.

  • @messi_codes
    @messi_codes ปีที่แล้ว +28

    confusing !

    • @Solo_playz
      @Solo_playz 7 หลายเดือนก่อน

      Rewatch the last video and then watch this again for 10 times your homework 😂

    • @Bcs-Mohtisham
      @Bcs-Mohtisham 7 หลายเดือนก่อน

      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

  • @sourabhrajwade1061
    @sourabhrajwade1061 5 หลายเดือนก่อน

    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 !

  • @jaidhingra2811
    @jaidhingra2811 หลายเดือนก่อน

    I didn't know, we can add multiple things while signing JWT.
    Thanks

  • @Star_Walker1
    @Star_Walker1 10 หลายเดือนก่อน +2

    Your explanation is very good

    • @flopgameryt399
      @flopgameryt399 8 หลายเดือนก่อน +1

      Can you provide me source code bcz my code not working after seeing this video 😢

    • @MuhammadFurqan-o6z
      @MuhammadFurqan-o6z 7 หลายเดือนก่อน

      @@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,
      }

  • @weforyouweb1165
    @weforyouweb1165 ปีที่แล้ว +2

    Superb video 🎉

  • @amansultanbaig7130
    @amansultanbaig7130 9 หลายเดือนก่อน +1

    can you make playlist for microservices with node & kafka ?

  • @RohitKumar-dy2gc
    @RohitKumar-dy2gc 8 หลายเดือนก่อน +1

    nice and easy

  • @PubG-dl5eh
    @PubG-dl5eh ปีที่แล้ว +2

    Thanks sir, for uploading this video👍🔥

    • @flopgameryt399
      @flopgameryt399 8 หลายเดือนก่อน

      Can you provide me source code

  • @Aitool-r3q
    @Aitool-r3q 9 หลายเดือนก่อน

    Amazing sir jee❤️👍

  • @newwasd
    @newwasd ปีที่แล้ว +4

    Hi Piyush,
    deployed azure api, done app registrations but req.headers.authorization underfined

  • @JatinKumar-i9k
    @JatinKumar-i9k 4 หลายเดือนก่อน

    Sir, the projects you have made in this node js series will help us to get a fresher level job for full stack role and can I add these projects in resume or I should make new real world project pls sir suggest me ..

  • @dev_vlog_7
    @dev_vlog_7 9 หลายเดือนก่อน

    Helping bro... Nice one

    • @flopgameryt399
      @flopgameryt399 8 หลายเดือนก่อน

      Can you provide me source code bcz my code not working after seeing this video 😢

  • @tarunjawla9463
    @tarunjawla9463 8 หลายเดือนก่อน +1

    can you please add the gitub link for this project?

  • @saisatyakundaram
    @saisatyakundaram 6 หลายเดือนก่อน +2

    i am getting error at req.headers ["authorization"] it is saying at headers???

  • @dipanshmalhotra
    @dipanshmalhotra ปีที่แล้ว +1

    OP!

  • @Cocfans3252
    @Cocfans3252 3 หลายเดือนก่อน +1

    Sir muje confusion hoo raha h 😟 .....Please suggest me some books to learn backend through MERN

  • @n001sourabhmahto3
    @n001sourabhmahto3 ปีที่แล้ว

    26th video completed watching of this playlist thanks piyush bhaiya. can u provide us the code.

    • @flopgameryt399
      @flopgameryt399 8 หลายเดือนก่อน

      Can you provide me source code

  • @silentworldsound
    @silentworldsound 9 หลายเดือนก่อน +2

    how to check the user is logged in or not in reactjs?

    • @ilikethemost
      @ilikethemost 9 หลายเดือนก่อน

      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

  • @ravikumawat23
    @ravikumawat23 5 หลายเดือนก่อน

    Guru ji , Please give us sourcecode also to read code for revison. Because our practice code not enough clear to read.

  • @Kiran__-kv4qx
    @Kiran__-kv4qx 11 วันที่ผ่านมา +1

    Did you say something 17:11

    • @Q-Productions23
      @Q-Productions23 4 วันที่ผ่านมา +1

      what did he say?

    • @Kiran__-kv4qx
      @Kiran__-kv4qx 3 วันที่ผ่านมา

      @Q-Productions23 chu

  • @satyajeetraj2366
    @satyajeetraj2366 ปีที่แล้ว +2

    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 6 หลายเดือนก่อน

      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.

  • @saisatyakundaram
    @saisatyakundaram 6 หลายเดือนก่อน +1

    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();
    }

  • @mannkawatkar2449
    @mannkawatkar2449 8 หลายเดือนก่อน +1

    Why You used youtube-app-1 database to update the user collection?? because in this application you were using short-url database..

    • @eliteboyfun280
      @eliteboyfun280 7 หลายเดือนก่อน

      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

    • @Vijayrajsingh5
      @Vijayrajsingh5 2 หลายเดือนก่อน

      same idk why he used youtube-app-1 db here and his code is also working idk how but mine is not working when i hit the url /admin/urls it returns UnAuthorized response then i changed the db to short-url and did the same changes in that db added the role field and updated to my role to ADMIN then it worked idk how his code is working!!!

  • @sushantdwivedi4407
    @sushantdwivedi4407 7 หลายเดือนก่อน +1

    Since you are busy in just coding your project and everything

  • @karankewat3071
    @karankewat3071 ปีที่แล้ว +1

    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.

  • @sahilsaini9976
    @sahilsaini9976 หลายเดือนก่อน

    It got bit complex and confusing because of the previous changes made from JWT cookie to JWT response 😵

  • @sushantdwivedi4407
    @sushantdwivedi4407 7 หลายเดือนก่อน +10

    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 5 หลายเดือนก่อน +2

      Yes I feel same !..

    • @supercargyan2362
      @supercargyan2362 4 หลายเดือนก่อน +2

      Same bro

    • @siddharthbehll
      @siddharthbehll 3 หลายเดือนก่อน

      Well that's true but you have to figure it out on your own use chatgpt google etc you will find it easy. yet this is the best playlist I have covered it all except graphQL

    • @kuchbhi-to2ru
      @kuchbhi-to2ru 2 หลายเดือนก่อน +2

      same brother

    • @WaseemAkram-tc9tl
      @WaseemAkram-tc9tl 7 ชั่วโมงที่ผ่านมา

      I too feel that

  • @mma-dost
    @mma-dost ปีที่แล้ว

    bhaiya great projects kab aayega bhaiya aap project react ke saath banao aur react bhi samja dena aisa theek rhega

  • @keybored7862
    @keybored7862 8 หลายเดือนก่อน +1

    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.

  • @niklausmikaelson7332
    @niklausmikaelson7332 6 หลายเดือนก่อน

    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

  • @sushantdwivedi4407
    @sushantdwivedi4407 7 หลายเดือนก่อน +1

    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.

    • @Pinakin_108
      @Pinakin_108 หลายเดือนก่อน

      same brooo 😑😑

  • @aqsayounis1289
    @aqsayounis1289 4 หลายเดือนก่อน

    how is the jwt token decoded without the key?

  • @hetjayeshbhaipatel1075
    @hetjayeshbhaipatel1075 7 หลายเดือนก่อน

    bhai apka fullstack project ka link kaha milega?

  • @Akash-nh8pc
    @Akash-nh8pc 5 หลายเดือนก่อน

    where to get these videos code on github, any link?

  • @adityalonkar8043
    @adityalonkar8043 3 หลายเดือนก่อน

    Can I get the code

  • @RaviKumar-gh9oh
    @RaviKumar-gh9oh 3 หลายเดือนก่อน

    where is the code?

  • @lovelymusic3549
    @lovelymusic3549 ปีที่แล้ว

    Sir we are waiting for react JS course?

    • @piyushgargdev
      @piyushgargdev  ปีที่แล้ว +1

      Ayega Ayega, React bhi ayega

  • @21UEI007MuskanGupta
    @21UEI007MuskanGupta 8 หลายเดือนก่อน

    Provide the code link or source code please

  • @siasquad7360
    @siasquad7360 4 หลายเดือนก่อน

    sir source code bhi de dete .

  • @divyanshukumar8440
    @divyanshukumar8440 5 หลายเดือนก่อน +1

    confused !!!!!

  • @prinspatel7515
    @prinspatel7515 3 หลายเดือนก่อน

    Bro sab video source code do