Added user data loader
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-12-06 03:55:59 +01:00
parent f7b5dc41ca
commit 02af4b667e
4 changed files with 64 additions and 17 deletions

View File

@@ -1,12 +1,39 @@
<template>
<div id="app">
<router-view/>
<md-snackbar md-position="center" :md-duration="4000" :md-active.sync="showWelcome">
<span>Welcome back {{ $store.state.auth.name }}!</span>
</md-snackbar>
</div>
</template>
<style>
<script>
</style>
import {mapState} from 'vuex';
export default {
name: "App",
data() {
return {
showWelcome: false
}
},
computed: mapState('auth', ['name']),
mounted() {
this.$store.dispatch("auth/loadUserData").catch(() => {
this.$router.push({name: "Welcome"});
})
},
watch: {
name(newValue, oldValue) {
if (oldValue === '') {
this.showWelcome = true;
}
}
}
}
</script>
<style>
#app {