summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2022-11-15 21:16:26 +0100
committerSanto Cariotti <santo@dcariotti.me>2022-11-15 21:16:26 +0100
commit0d09a4eac92da6d8dd2de91ce7ad5fea1e75116d (patch)
treeadc14a6e7723ed31385ccf1ab7c59f4adacb61cf
parent71300fa1aebd76d448cd810e32b7bfa5569afb29 (diff)
Redirect if a login expires
-rw-r--r--app/src/views/UserInfo.vue15
1 files changed, 13 insertions, 2 deletions
diff --git a/app/src/views/UserInfo.vue b/app/src/views/UserInfo.vue
index 04259da..34c87b1 100644
--- a/app/src/views/UserInfo.vue
+++ b/app/src/views/UserInfo.vue
@@ -7,6 +7,7 @@
<p>Name: {{ me.name }}</p>
<p>Email: {{ me.email }}</p>
<p>Is staff: {{ me.is_staff }}</p>
+ <ion-button @click="makeLogout">Logout</ion-button>
</div>
</ion-content>
@@ -36,10 +37,20 @@ export default defineComponent({
created() {
if (!this.isLogged) window.location.href = "/sign";
- this.getMe();
+ this.getMe()
+ .then(() => {
+ if (!this.isLogged) window.location.href = "/sign";
+ })
+ .catch(() => {
+ window.location.href = "/sign";
+ });
},
methods: {
- ...mapActions("auth", ["getMe"]),
+ makeLogout() {
+ this.logout();
+ window.location.href = "/sign";
+ },
+ ...mapActions("auth", ["getMe", "logout"]),
},
});
</script>