Angular Guards | Angular Auth Guard | Angular Canactivate

Поділитися
Вставка
  • Опубліковано 29 січ 2023
  • Learn Angular guards by implementing Angular auth guard. This is the most popular way to protect your pages for unathorized users with Angular canactivate method.
    ► CHECK MY COURSES - monsterlessons-academy.com/co...
    FOLLOW ME
    ► TWITTER - / monster_lessons
    REFERENCES
    ► Source code - github.com/monsterlessonsacad...

КОМЕНТАРІ • 34

  • @user-tx3jz2id7n
    @user-tx3jz2id7n 9 днів тому

    Thank you so much for this, I have been on the struggle bus.

  • @mikhailratner4649
    @mikhailratner4649 Рік тому +13

    I like your content but class-based guards (and resolvers) are deprecated from Angular 15.2. Hoped to see how you implement functional guards, but maybe that's a good topic for another video and I can imagine many people will search specifically for this from now on :)

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

    Awesome, very useful!

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

    Awesome, easy to understand

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

    damn, you made it look easy but this is hard to undertand. Thanks bro

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

    Awesome video. Could you please also provide a video about the future of angular comparing with react

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

    💯

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

    Hi and thanks. What about function-style guards?

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

      You are welcome! You can for sure also usee function style guards, the difference is minimal

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

      @@MonsterlessonsAcademy It's not that minimal actually. It turns out you don't have access to DI in the functions, as they are not in an injector scope unless you are using a standalone component. That necessitates some further complications and workarounds such as the use of EnvironmentInjector and/or some other tricks.

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

      @@gkarapeev Thanks for the info. I will plan some videos on them then!

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

      @@MonsterlessonsAcademy great, thank you, looking forward to seeing them. :)

  • @ThanHtutZaw3
    @ThanHtutZaw3 5 місяців тому

    i only get currentUser value undefined in canActivate Function . const authService = inject(AuthService); export const hasRoleGuard: CanActivateFn = (route, state) => { return authService.currentUser$.pipe( ) etc ....

  • @oriollpz
    @oriollpz 8 місяців тому

    What about is you want to guard from the server side?

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

    One question: there are many react clones of popular websites tutorial on youtube, can we code a clone and add to our public github repository ? I don't want to use it for any business or sell it to somebody. I want to use it just to get job, that shows my skills

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

      Yes sure you can but you must be able to answer questions about every single line in a project. In other case people will think that you just copied it.
      Another problem that "coding a clone" by tutorial doesn't equal your code written from scratch. So it may be to polished and far from the code that you write.

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

      @@MonsterlessonsAcademy so if i create google clone and used google logo, its not illegal to put it in my public github repo?

    • @Mooplebot-zk4rp
      @Mooplebot-zk4rp 11 місяців тому

      Oh god... It will be so embarassing when they find out you didnt create that work

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

    deprecated canActivate

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

    canactivate is depracted...

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

      I already made a video about new way of canactivate
      ua-cam.com/video/Yc93IvrouxY/v-deo.htmlsi=Mc_BDRHVXQIqzPw_

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

      @@MonsterlessonsAcademy that is great! exacly what i looked for, good video thanx, maybe you should add a link to it as update in ur video ;) beacuse Functional Guards wasnt clear to me, as i looked for canactivate depracated