NodeJS API Authentication using JWT Tokens

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

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

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

    Awesome! Concise and straight forward!

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

    For whom getting jwt undefined in /user
    In your router file, write this:
    const cookieParser = require("cookie-parser")
    Then add:
    router.use(cookieParser());
    and remove same this code from your App.js file

  • @rahulsriram6295
    @rahulsriram6295 3 ปีที่แล้ว +3

    Thank you so much! Great video. Waiting for NestJS implementation. Also try argon2 instead of bcryptjs, its algorithm is better and there isn't a need for generating salt in case of argon2, just hash and unhash.

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

      Thank you for the tip, I will change them in my future videos. The NestJS Video will be uploaded after 2 weeks, 1st of March.

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

    Finally a great, complete and working tutorial. Really thank you

  • @jonathancolorado2998
    @jonathancolorado2998 2 ปีที่แล้ว

    Thanks I always learn with you, what a great programmer you are.
    Greetings from Colombia

  • @maskman4821
    @maskman4821 3 ปีที่แล้ว

    Thank you, I have learned a lot, setting up a nodejs/expressjs server and handle all of the route functionality is cool but tedious, that's why serverless is popular these days, it takes care of the repetitive work for us, anyhow, it is always good to know how to setup a server and handle all of the tasks ourselves, great tutorial 😀

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

    tks u so much, u are a lifesaver, i was looking for this the whole day

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

    Great video. It truly saved a lot of hassle. Thank you.

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

    Very clear, thank you for the video.

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

    the thing that I dont understand is why we store the user info in the cookies. Why didnt we created any session for that?. Great video. love it

  • @НикитаЮрент
    @НикитаЮрент 3 หลายเดือนก่อน

    Thanks 🙌 Best lesson

  • @Amasha-Shade
    @Amasha-Shade 8 หลายเดือนก่อน

    truly helpful..
    thank you!

  • @mehmetaltinsoy525
    @mehmetaltinsoy525 2 ปีที่แล้ว

    Great video.Thanks.

  • @rumble_bird
    @rumble_bird 2 ปีที่แล้ว

    That is really helpful, thanks a lot!!

  • @makkujapan8123
    @makkujapan8123 3 ปีที่แล้ว

    Very good tutorial. Thank you for this! I don't really get where to store the secretKey. Can you explain again?

  • @podSnippets_10
    @podSnippets_10 2 ปีที่แล้ว

    27:37 this happens because the data we want to get can be displayed by using this syntax const {password, ...data} = user._doc;
    res.send(data)

  • @jozmat2268
    @jozmat2268 3 ปีที่แล้ว

    You can make one with MySQL and
    typeorm? All in typescript with interfaces implementation?

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

    Nice tutorial... how about refresh token...and a react/redux front end?

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

      First check the links in the description of the video, there I have the react frontend. Second I didn't include refresh token and redux because I wanted everything to be simple.

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

    sir at 12:05, when I try to test in postman and click send, it was loading forever with the statement in terminal:
    "message": "Operation `users.insertOne()` buffering timed out after 10000ms"
    Can you please tell me how to solve this?

  • @nnagap72
    @nnagap72 3 ปีที่แล้ว

    Hello, thank you for the tutorial. I have one question. For example, we have a user with N products. How to use this cookie to fetch all products belonging to the logged in user ?

  • @igorpanov2667
    @igorpanov2667 3 ปีที่แล้ว

    Big thanks!

  • @ainneo
    @ainneo 3 ปีที่แล้ว

    I am having trouble connecting this to the frontend react part.... how can we connect this to the frontend????

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

    the JWT cookie displayed in POSTMAN but not in Browser, what can i do ? i am using Vue

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

      elon musktache

  • @ghaithbouslimi9574
    @ghaithbouslimi9574 2 ปีที่แล้ว

    const cookie = req.cookies['jwt']
    TypeError: Cannot read properties of undefined (reading 'jwt')

  • @maryrs9753
    @maryrs9753 3 ปีที่แล้ว

    Thank you 🙏

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

    What is the reason for not set the token to auth request header as bearer token?

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

    This is great but Need help with an issue I am facing with this,
    I hosted the BE on Aws EC2, and this works great on my localhost frontend app,
    But as soon as I host the FE on Aws S3, the cookie doesnt get set in the browser anymore, also there is the warning sign near the cookie in the Login response header. So none of my next requests are working after that as their request header does not have the cookie. (Works perfectly on my localhost)
    Does anyone know why ?

  • @MrMehdiBenAyed
    @MrMehdiBenAyed 2 ปีที่แล้ว

    Thank you :)

  • @GeorgeMartinJose
    @GeorgeMartinJose 3 ปีที่แล้ว

    Thank you so much

  • @jamols09
    @jamols09 3 ปีที่แล้ว

    Is it okay to request for a video of this with fastify being used?

  • @priyanshusingh313
    @priyanshusingh313 3 ปีที่แล้ว

    hii it is absolutely great but I wanted help to connect this node.js backend to react frontend, can anyone help

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

    I can’t delete cookie! Please help

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

    Great

  • @samuelsaturno8149
    @samuelsaturno8149 2 ปีที่แล้ว

    For some reason when I use the webpost it doesn't receive or send the id as shown in the video. Is it because I use the site or do I have to install it?

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

    will this work with the React JWT Authentication code?

    • @ScalableScripts
      @ScalableScripts  3 ปีที่แล้ว

      yes, it will work with all the links provided in the description

  • @hasyidanparamananda
    @hasyidanparamananda 2 ปีที่แล้ว

    What is this cookie for?

  • @anishbishnoi29xD
    @anishbishnoi29xD 3 ปีที่แล้ว

    sir make Protect route. Login user can't access Signup page.
    if user already Login in then don't go to login page again.
    and other route protect. If not login don't go home page or other routes
    and make Video store Token in Mongodb Database and delete from there and verify from there. and Token expire date etc.
    and make video Authentication with Facebook and Google In Node Js also.

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

      I think your are mix all, if you use vuejs for exemple you should handle that with vuejs this is a api only give status of the pages and data i think the goal was that!

  • @ardilawar66
    @ardilawar66 2 ปีที่แล้ว

    👏👏👍

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

    thanks, like + subscribe

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

    I am getting this error on post register:
    C:\Angular\product-display-system-cms\backend
    ode_modules\bcryptjs\dist\bcrypt.js:214
    nextTick(callback.bind(this, Error("Illegal arguments: "+(typeof s)+', '+(typeof salt))));
    ^
    Error: Illegal arguments: undefined, string
    at _async (C:\Angular\product-display-system-cms\backend
    ode_modules\bcryptjs\dist\bcrypt.js:214:46)
    at C:\Angular\product-display-system-cms\backend
    ode_modules\bcryptjs\dist\bcrypt.js:223:17
    at new Promise ()
    at bcrypt.hash (C:\Angular\product-display-system-cms\backend
    ode_modules\bcryptjs\dist\bcrypt.js:222:20)
    at C:\Angular\product-display-system-cms\backend
    outes
    outes.js:7:41
    Any suggestions on how to fix this? Thank you!

  • @ghaithbouslimi9574
    @ghaithbouslimi9574 2 ปีที่แล้ว

    i have this error in post('/login)
    in const user = User.findOne({email:req.body.email})
    TypeError: Cannot read properties of undefined (reading 'findOne')
    help me please