diff options
author | Santo Cariotti <santo@dcariotti.me> | 2022-11-15 21:16:26 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2022-11-15 21:16:26 +0100 |
commit | 0d09a4eac92da6d8dd2de91ce7ad5fea1e75116d (patch) | |
tree | adc14a6e7723ed31385ccf1ab7c59f4adacb61cf /app/src | |
parent | 71300fa1aebd76d448cd810e32b7bfa5569afb29 (diff) |
Redirect if a login expires
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/views/UserInfo.vue | 15 |
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> |