Last active
May 9, 2019 02:45
-
-
Save gdbate/92a35c14470987d3a6a49dc9b291f82f to your computer and use it in GitHub Desktop.
Vue: Customizing Amplify Authentication - Handling Authentication Changes
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
| { | |
| watch: { | |
| '$store.state.account.authorized': async function(n, o){ | |
| if(n, o){ | |
| //logic for user logging in | |
| await this.$api('user', 'signin') //example for logging in user to server | |
| if(this.$route.path !== '/' || !o) | |
| this.$router.push('/') | |
| }else{ | |
| //logic for user logging out | |
| if(this.$route.path !== '/') | |
| this.$router.push('/') | |
| } | |
| }, | |
| }, | |
| // attempt to login user from session | |
| async created(){ | |
| await store.dispatch('account/fetchUser') | |
| }, | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment