Learning Vue JS - Auto Logout

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ก.ย. 2024
  • In this lesson, we are exploring how to systematically log a user out of our application using Vue. Let's start by adding some event listeners on the windows and then starting some timers. As events start rolling in, we will restart those timers until one of those expire. When they do, we will log the user out.
    For the best experience, follow along in our interactive school at www.coderstape...
    DigitalOcean Referral
    m.do.co/c/7dce...

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

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

    Welcome back 💪
    As for the "this" keyword it is another option to use arrow function :)
    Nice tutorial though, thank you

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

    I could not have asked for a better walk-trough and explanation of how to do this. You made it look so easy (and it was) and you are a really good presenter. Exactly what I was looking for. I implemented a snackbar for the warning for a bonus. Thank you!

  • @typ0_cratz
    @typ0_cratz 4 ปีที่แล้ว

    I use laravel at work everyday, and honestly if I want to learn or understand new features, I always come to your channel :) you are the best

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

    welp, this is a great surprise; I was just about to search your channel to finish the Laravel Collection series.

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

      Love that series, was a lot of fun to put together

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

    You are an amazing teacher!

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

    Bro, you simplified this for me man. Great job. 👏👏👏

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

    Miss your videos so much. This video again and again was helpful!

  • @QiroLab
    @QiroLab 4 ปีที่แล้ว

    nice video, at 12:09 you can also use the es6 arrow function, it will bind `this` automatically. You don't have to pass `this` in that case.
    example:
    ```
    this.events.forEach(event => {
    window.addEventListener(event, this.resetTimer);
    })
    ```

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

      I think I mentioned that on the video. We could use fat arrow functions to get the this binding but opted in to show the traditional way for learning purposes.

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

    Good coding. Excellent explanation.

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

    nice video. I hope you will make more videos :)

  • @dieguinosorio6265
    @dieguinosorio6265 4 ปีที่แล้ว

    Super bien explicado, lo estaba buscando hace mucho tiempo muchas gracias.

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

    Been a while since you uploaded, or at least I got a notification! It's going to be a series?

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

      That's the plan

  • @lobobogard9236
    @lobobogard9236 4 ปีที่แล้ว

    you save me in my project thnx from mexico

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

    I prefer to create after warning a countdown to logout

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

    Victor. Great content &great explanation.did you have plan to make course on machine learning.??

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

    No offence, but your code is _vastly_ inefficient. Clearing and setting timeouts with every mouse move leads to timeout ID sky rocket. Also, I don't quite understand why you need two separate counters. You just measure inactivity time in both timers, so the timer itself could serve as that - an inactivity counter. Your warning and logout code should consume the counter instead of defining their own. The cleanest and most efficient solution to this problem is to store inactivity time somewhere and make it 0 if either of these events occur. Then, each tick would check if the inactivity is greater or equal the amount of time triggering warning or the logout.
    Also, _click_ doesn't make any sense if you have mousedown and keydown. Either of these _always_ precedes the click.

    • @maratimus
      @maratimus 4 ปีที่แล้ว

      Yeah

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

      I totally agree. also timers have the side effect that they do not run when the tab in your browser is inactive. So to improve on the idea of a inactivity counter you should check against a timestamp when the events occur and calculate a deltatime to check against a threshold. In addition you need an check at the backend for a valid session cookie. Ideally it also provides the max activity time for the user, just to keep the configuration of your app save. As any kid in the school could easily change the javascript or disable it altogether.
      But to get the concept along and show the versatility of components it's a great tutorial... just do not use it in production.

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

      Mega Bub: Like to share a bit of code as to how you would go about this task?

  • @newsupdates-yz5dp
    @newsupdates-yz5dp 4 ปีที่แล้ว

    Hey Vicktor Welcome back 😁

  • @MyNguyen-xb1gv
    @MyNguyen-xb1gv 2 ปีที่แล้ว

    Thank you my boss!!!

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

    Thank you for the tutorial, it's been a month since your last upload.
    Very informative and easy to understand.
    I have one question about the destroyed event, why we need to implement it in this scenario?
    I don't think it will ever be called, since the component is always mounted and there is no event to remove it from the DOM.
    Sorry for the bad English. 😅

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

      It will be fired automatically when you navigate to the next page and Vue does the cleanup

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

    Nice tutorial thank you!
    Any idea if implementing a throttle is a good idea? 🤔

  • @ДавидИванов-г3ж
    @ДавидИванов-г3ж 4 ปีที่แล้ว

    What a great video. Can u make make video about services and repositories in laravel - pros and cons. I have already watched your video about Repository pattern but it will be good if u have that type of lesson. Greetings! 👏

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

    Excelent!!

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

    Awesome! you are awesome man

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

    good amingzing hahah

  • @Adbal99
    @Adbal99 4 ปีที่แล้ว

    Would you make more any vue-laravel real life components in the future? I am at very beginning level with js and Vue, so it would be nice to have some simple real world examples.
    Really nice tutor btw!

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

    Is there any way to logout on all tabs?

  • @cubedev4838
    @cubedev4838 4 ปีที่แล้ว

    Amazing!!

  • @tiagogitz
    @tiagogitz 4 ปีที่แล้ว

    really nice , thank you

  • @kmtsvetanov
    @kmtsvetanov 4 ปีที่แล้ว

    Can you show us the best way to authenticate using OAuth2 and JWT? Thank you!

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

    Hi Victor! Do you also have vuex tutorials? Thanks

  • @principe.borodin
    @principe.borodin 4 ปีที่แล้ว

    Very interesting, and how do with page visibility of html5?

  • @walidbagh
    @walidbagh 4 ปีที่แล้ว

    he's back

  • @welt101
    @welt101 4 ปีที่แล้ว

    But if a user disables javascript this wouldn't work

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

      The same can be said about literary everything that uses Javascript. There's no fix for that

    • @welt101
      @welt101 4 ปีที่แล้ว

      @@CodersTape That's true. Btw nice video as always 👌

  • @FranciscoSierraLDU
    @FranciscoSierraLDU 4 ปีที่แล้ว

    Hey!!! great video, thanks for posting it, just an observation... isn't the listener for mousemove a lot of overhead? ... I mean, that event occurs absolutely all the time.

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

      Yes I agree. In the real project, I actually used lodash to debounce the event to once a second.

    • @FranciscoSierraLDU
      @FranciscoSierraLDU 4 ปีที่แล้ว

      @@CodersTape That sounds absolutely better. Thanks!!!

  • @aangGAD
    @aangGAD 4 ปีที่แล้ว

    How can I get the theme you are using? Love it :)

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

    Appliated much if you can make video auto logout integrated with JWT.

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

    haha amingzing

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

    Where are you brother, miss a lot...😢😢

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

    Where can i find the full coding!!!!

  • @vanharrislavega5631
    @vanharrislavega5631 4 ปีที่แล้ว

    Can you please do a toturial about ionic sir 😊🙏

  • @agun21st
    @agun21st 4 ปีที่แล้ว

    brother are you continue Vue Js Learning course? I want to learn from this tutorial

  • @coderflex5818
    @coderflex5818 4 ปีที่แล้ว

    Like without watching 😁
    Keep going 💪

  • @youngjojo3052
    @youngjojo3052 4 ปีที่แล้ว

    You the man, any new Udemy courses?

  • @mdmonirulislam4555
    @mdmonirulislam4555 4 ปีที่แล้ว

    Bro when your Udemy course come?

  • @Stoney_Eagle
    @Stoney_Eagle 4 ปีที่แล้ว

    Now I have a reason to hate you 😂
    I HATE being logged out automatically.
    It's a nessesary evil tho. 😉

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

      Just another tool in the toolbox my friend