From debcb330e1243c18f22fa56661b2e3b428e80368 Mon Sep 17 00:00:00 2001 From: Troplo Date: Mon, 12 Apr 2021 00:10:54 +1000 Subject: [PATCH] Email Verification + Session Invalidation --- src/locales/en.json | 5 +++ src/router/index.js | 5 +++ src/views/EmailVerify.vue | 78 ++++++++++++++++++++++++++++++++++ src/views/SettingsSecurity.vue | 24 ++++++++++- 4 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 src/views/EmailVerify.vue diff --git a/src/locales/en.json b/src/locales/en.json index afd3482..7b1b367 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -276,6 +276,11 @@ }, "resend": { "resend": "Resend Email Verification" + }, + "session": { + "title": "Invalidate all sessions", + "subtitle": "Using this feature will log you out of all devices, including this one!", + "invalidate": "Invalidate sessions" } }, "privacy": { diff --git a/src/router/index.js b/src/router/index.js index 403e59a..0bf7726 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -187,6 +187,11 @@ const routes = [{ { path: 'about', component: route('SettingsAbout') }, ] }, + { + path: '/verify/:code', + name: 'EmailVerify', + component: route('EmailVerify') + }, { path: '*', name: '404', diff --git a/src/views/EmailVerify.vue b/src/views/EmailVerify.vue new file mode 100644 index 0000000..4aba744 --- /dev/null +++ b/src/views/EmailVerify.vue @@ -0,0 +1,78 @@ + + + + + \ No newline at end of file diff --git a/src/views/SettingsSecurity.vue b/src/views/SettingsSecurity.vue index d40f162..ff9de28 100644 --- a/src/views/SettingsSecurity.vue +++ b/src/views/SettingsSecurity.vue @@ -25,6 +25,11 @@ {{$t('settings.security.email.change')}} +
+
{{$t('settings.security.session.title')}}
+

{{$t('settings.security.session.subtitle')}}

+
+ {{$t('settings.security.session.invalidate')}} @@ -34,7 +39,7 @@ import AjaxErrorHandler from "@/assets/js/errorHandler"; import axios from "axios"; export default { - name: "SettingsSecurity", + name: "SettingsAccount", data() { return { password: { @@ -56,6 +61,9 @@ export default { }, resend: { loading: false + }, + session: { + loading: false } } }, @@ -130,6 +138,20 @@ export default { this.resend.loading = false AjaxErrorHandler(this.$store)(e); }) + }, + invalidateSessions() { + this.session.loading = true + this.axios.put(process.env.VUE_APP_API_ENDPOINT + process.env.VUE_APP_API_VERSION + `/` + `users/preferences`, { + invalidateSession: true + }) + .then(() => { + this.session.loading = false + this.logout() + }) + .catch((e) => { + this.session.loading = false + AjaxErrorHandler(this.$store)(e); + }) } } }