aboutsummaryrefslogtreecommitdiff
path: root/client/src/App.vue
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/App.vue')
-rw-r--r--client/src/App.vue27
1 files changed, 25 insertions, 2 deletions
diff --git a/client/src/App.vue b/client/src/App.vue
index f2bef74..f61f236 100644
--- a/client/src/App.vue
+++ b/client/src/App.vue
@@ -17,7 +17,7 @@
</router-link>
</li>
</ul>
- <ul class="navbar-nav mb-2 mb-lg-0">
+ <ul class="navbar-nav mb-2 mb-lg-0" v-if="!isLoggedIn">
<li class="nav-item">
<router-link class="nav-link" active-class="active" to="/register">Register</router-link>
</li>
@@ -25,6 +25,11 @@
<router-link class="nav-link" active-class="active" to="/login">Login</router-link>
</li>
</ul>
+ <ul class="navbar-nav mb-2 mb-lg-0" v-else>
+ <li class="nav-item">
+ <span class="nav-link" @click="logout">Logout</span>
+ </li>
+ </ul>
</div>
</div>
</nav>
@@ -34,11 +39,29 @@
</template>
<script>
+import axios from 'axios';
+
export default {
- name: 'Checkout',
+ name: 'App',
+ created() {
+ axios.interceptors.response.use(undefined, error => {
+ if (error.status === 401) {
+ this.$store.commit('auth_clean');
+ }
+ return Promise.reject(error);
+ });
+ },
computed: {
cartSize() {
return this.$store.getters.getCartSize;
+ },
+ isLoggedIn() {
+ return this.$store.getters.isLoggedIn;
+ }
+ },
+ methods: {
+ logout() {
+ this.$store.commit('auth_clean');
}
}
}