Nest.js - full authentication course

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

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

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

    I was struggling to understand the NestJS Authentication, but having seen this video. I am now able to setup the NestJS Authentication, thank you so much!

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

    Thank you so much Mike dev, now i know how to extractJwt from cookies in JwtStrategy, thanks again!

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

    "They have a cat image, it's supposed to be good" 🤣
    And actually it's good, thanks for the education BTW.

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

    Saved my life man, the NextJS docs are kinda weird when it comes to auth.

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

    Explaination is very good but I faced error like everytime I get 401 UnAuthorized Access. My JWTToken and cookie generated successfully and also then contained correct credentials

  • @khal-elbangcola8167
    @khal-elbangcola8167 2 ปีที่แล้ว +1

    Thank you Sir for sharing your knowledge. Much appreciated.

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

    I feel like you could keep the service lvl cleaner like this: in sign in logic, you didn't have to pass req and res to the service level and could've handled as follows:
    At the service level: async sign-in(dto) {
    ...The rest of your code
    return token;
    }
    And then at the controller level:
    async sign-in(dto, req, res) {
    const token = await this.authService.sign-in(dto)
    req.cookie("jwt", token, {...Your cookie options}).
    }

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

    how to use myuser api for fetching data... i get error unauthorised when i call from react frontend, i set token in token in cokies using jwt-token, then pass it by headers .. but not work.please give a axios example.. its urgent

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

    I want to build a rest api that will be consumed by react admin(front-end) using sessions/http-only cookies and a mobile app using jwt tokens(stateless). Please can you advise me on how to structure/Architect my NestJS project to help me build this?

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

      Do you ask how to separate the web method from the mobile? or how to implement this methods?

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

    Please make a Playlist of nest js

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

    How can i check if user already sign or not ?
    In front end

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

      You can have isAuth flag stored somewhere globally in your app, and after the login change it to true. If you want to check or get some info from server private route your client should send the jwt cookie for validating your user.

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

      @@mikedev4673 yes but what is token is dead and how can i check if it dead and redirect user to login page or something?

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

      or i should have a function to get data from private route if failed user direct to login page

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

      @@reanyouda8299 yes it is possible to do it like that and to make a token to expire you can define how long the token will last at the jwt options.

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

    Thank you for this video, what I was looking for exactly

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

    you can run prisma db push instead of the prisma migrate dev

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

      Thanks I will take a look at that

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

    can you do it with refreshToken?

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

      It is quite an overkill but I will consider making a real project and include that

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

    Hi, what should i do?
    JwtStrategy requires a secret or key

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

      did you make .env file with the jwt secret?

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

    Thanks for the great tutorial , you have any idea about how to send mail verification and forgot password please ?

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

      I did it before it was a long time ago but I think I just used some mailing service, you can check sendgrid or mailchimp

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

      @BenfredjMaissa Did you ever find out how to do email verification and password recovery?

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

    Hi! Thank you very much for your video. I followed your tutorial, but I encountered a problem. When I try to post the email and password, nest.js will have an error: Invalid `prisma.users.create()` invocation in xxx and : Query createOneusers is required to return data, but found no record(s). Do you know how to solve this?

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

      Hi try to debug this with console logs I don't sure what this error is but check what causes it, put logs on your email and password and on the result on the result of the creation maybe

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

      @@mikedev4673 Thank you very much ! I solved this by use createMany() instead of create(), but I still don't know why.

  • @ВладимирГригин-п9о
    @ВладимирГригин-п9о ปีที่แล้ว

    Greate job! Need frontend with NextJS to this backend and rename fullstack to PPNN(Postgress+Prisma+Nest+Next). Patent plz :)

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

      It's actually made me laugh lol, but a good idea I will consider making a real project with this stuck not just authentication

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

    This is a great tutorial, Thanks

  • @VIKTOR-pw8eu
    @VIKTOR-pw8eu 2 ปีที่แล้ว

    Thanks for the great tutorial!

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

    Thank you so much, your video is perfect. I was looking for, but didn't find anthing while i saw youre video.
    Interesting moment for me, 1:29:28 you logged by test2 account, but you can see test email and coun't see test2? Is it true? Or i misunderstood you maybe. I wish you a lot of subscribles.
    if i have some mistakes, i am sorry🤭

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

      hi I can see why it may be confusing but I was logged in as just test, the fields you see in the body doesn't actually matter we are making a get request so it doesn't matter what is there

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

    Thanks you haved help me.

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

    Very good course

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

    nice tutorial

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

    Please make amazon clone

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

    dude great video but damn why are you so slow

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

    I follwed your course, and all works fine but guards. I cloned your project also and tried, but still when I put @UseGuards(JwtAuthGuard) I am facing 401 unauthorized error

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

      Hi, did you try to "login" first with postman?
      you should have a cookie to pass the guard

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

      @@mikedev4673 hey! It seems to me that I have the same error.
      {
      "statusCode": 401,
      "message": "Unauthorized"
      }
      And Yes, I logged in and I have the Cookies in the Postman.
      Everything works, except this, it tells me Unauthorized no matter what.

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

      @@galkristofhun ok I will check this issue

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

      @@mikedev4673 thanks, although now I don't remember how, but I managed to solve it.

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

      Did you find where is the error? thx@@galkristofhun