Skip to content

Instantly share code, notes, and snippets.

@mfreeman451
Last active March 29, 2019 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfreeman451/502adbad4167cb7f509551af5493366d to your computer and use it in GitHub Desktop.
Save mfreeman451/502adbad4167cb7f509551af5493366d to your computer and use it in GitHub Desktop.
Amplify-quasar-demo
<template>
<div id="q-app" v-if="hydrated">
<router-view/>
</div>
</template>
<script>
export default {
name: 'App',
data () {
return {
signedIn: false,
hydrated: false
}
},
async mounted () {
await this.$apollo.provider.defaultClient.hydrated()
this.hydrated = true
},
beforeCreate () {
this.$AmplifyEventBus.$on('authState', info => {
if (info === 'signedIn') {
this.signedIn = true
this.$router.push('/')
}
if (info === 'signedOut') {
this.$router.push('/auth')
this.signedIn = false
}
})
this.$Auth.currentAuthenticatedUser()
.then(user => {
this.signedIn = true
})
// eslint-disable-next-line
.catch(() => this.signedIn = false)
}
}
</script>
<style>
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment