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.

КОМЕНТАРІ • 33

  • @princepiyushsingh5758
    @princepiyushsingh5758 Рік тому

    This is exactly what I am searching and you have explained it very well.
    Thank you

  • @muhammadmuneebwaseem504
    @muhammadmuneebwaseem504 4 місяці тому

    Great course brother. Learning Nestjs for the first time and you nailed it! Thanks once again.

  • @phvntiendat
    @phvntiendat Рік тому +2

    This is by far the best course I've ever came across. Thank you

  • @alexmuchiri7786
    @alexmuchiri7786 Рік тому

    Amazing work @Abbas. God bless

  • @sepsartist7538
    @sepsartist7538 Рік тому

    Bro,
    This is exactly what is was searching.
    JAZAK ALLAH.

  • @awaraamin6850
    @awaraamin6850 7 місяців тому

    Great work

  • @tomascaetano4270
    @tomascaetano4270 Рік тому

    Superb 🎉🎉🎉

  • @AFUSquad
    @AFUSquad Рік тому

    great job ur videos tut helpful for me to doing uni project tyty

  • @ashishkumari-yg4gn
    @ashishkumari-yg4gn Рік тому

    Thank you sir

  • @ezequielotoni3228
    @ezequielotoni3228 Рік тому

    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

  • @ShahabMusharraf-ug8lu
    @ShahabMusharraf-ug8lu 2 місяці тому

    Why do we not saved the token in cookie?

  • @sifenbeshada8416
    @sifenbeshada8416 7 місяців тому

    How to implement a role-based authorization

  • @lucasdamasceno7068
    @lucasdamasceno7068 Рік тому

    great course bro, thanksss. it's more used the express or the nestjs ?

  • @gisssk9236
    @gisssk9236 6 місяців тому +1

    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

    • @Savangex
      @Savangex 6 місяців тому

      I have the same issue, have you found a solution yet?

    • @mokhlestarmiz743
      @mokhlestarmiz743 6 місяців тому

      @@Savangex same here :(

    • @phantazzor
      @phantazzor Місяць тому

      the user is simply undefined

  • @AFUSquad
    @AFUSquad Рік тому

    How about update and delete by check the user is owned the book

    • @codingwithabbas
      @codingwithabbas  Рік тому

      You can add if check and make sure the user is same. if(req.user._id != book.user) then throw the error.

  • @spizer98
    @spizer98 Рік тому

    how to implement logout functionality

    • @codingwithabbas
      @codingwithabbas  Рік тому +1

      This will be implemented on the frontend. We just need to clear the token.

    • @spizer98
      @spizer98 Рік тому

      @@codingwithabbas what if anyone copy the token use it to login so there might be a security problem

    • @codingwithabbas
      @codingwithabbas  Рік тому

      We store our token at safe place, like httpOnly cookies, that cannot be accessed from frontend,

    • @zekariyasmulugetaaltaye1065
      @zekariyasmulugetaaltaye1065 Рік тому +1

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

    • @chugia6118
      @chugia6118 Рік тому

      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!

  • @nathanzebedee5263
    @nathanzebedee5263 Рік тому

    awuawodawd

  • @jaxontn
    @jaxontn 27 днів тому

    Your tutorials are so long

    • @codingwithabbas
      @codingwithabbas  27 днів тому +1

      I will try to make short but sometimes in-depth explanation is necessary.

  • @ShahabMusharraf-ug8lu
    @ShahabMusharraf-ug8lu 2 місяці тому

    Why do we not saved the token in cookie?