Last active
November 14, 2019 14:32
-
-
Save shawndeprey/84803756763811607f1f46a4d70eb3c8 to your computer and use it in GitHub Desktop.
IdleVue implementation for SPA timeout article
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import IdleVue from "idle-vue" | |
const eventsHub = new Vue() | |
Vue.use(IdleVue, { | |
eventEmitter: eventsHub, | |
idleTime: 900000, // 15 Minutes | |
}) | |
new Vue({ | |
// ...Your vue config will be here. Below it add: | |
onIdle() { | |
// Replace the following 2 lines to match 1) How you store your sessions in your vue app and 2) your signin/login route. | |
this.$store.dispatch("auth/destroyCurrentSession") | |
router.replace("signin") | |
}, | |
onActive() { | |
// We're not using this function in this example, however, if you wanted a dialog to display | |
// before a user's session times out then you could use a shorter `idleTime` above and open | |
// a dialog in the `onIdle` function above. | |
}, | |
}).$mount("#app") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment