Add username chip
>
<span class="sr-only">Toggle navigation</span>
</a>
+ <v-chip
+ class="user_chip"
+ close
+ v-model="loggedIn"
+ color="green"
+ text-color="white"
+ >
+ <v-avatar>
+ <v-icon>check_circle</v-icon>
+ </v-avatar>
+ {{displayName}}
+ </v-chip>
</nav>
</header>
<!-- Left side column. contains the logo and sidebar -->
@@ -67,19 +79,49 @@ export default {
fixed_layout: config.fixedLayout,
hide_logo: config.hideLogoOnMobile
},
- error: ''
+ error: '',
+ loggedIn: true
+ }
+ },
+
+ computed: {
+ displayName () {
+ return this.$store.state.user
+ }
+ },
+
+ watch: {
+ loggedIn () {
+ if (this.loggedIn === false) {
+ this.logout()
+ }
}
},
methods: {
changeloading () {
this.$store.commit('TOGGLE_SEARCHING')
+ },
+
+ logout: function () {
+ this.$store.commit('SET_USER', null)
+ this.$store.commit('SET_TOKEN', null)
+
+ if (window.localStorage) {
+ window.localStorage.setItem('user', null)
+ window.localStorage.setItem('token', null)
+ }
+
+ this.$router.push('/login')
}
}
}
</script>
<style lang="scss">
+.user_chip {
+ margin-top: 8px;
+}
.wrapper.fixed_layout {
.main-header {
position: fixed;
