#85 universal login across locales - logout
This commit is contained in:
parent
f8e042d91d
commit
41e141b917
|
@ -1,5 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
<section>
|
<section v-if="logoutInProgress">
|
||||||
|
<p class="text-center">
|
||||||
|
<Spinner size="5rem"/>
|
||||||
|
</p>
|
||||||
|
<div>
|
||||||
|
<iframe v-for="domain in universalDomains"
|
||||||
|
:src="`${domain}/api/user/logout-universal`"
|
||||||
|
style="width: 1px; height: 1px; opacity: .01"
|
||||||
|
>
|
||||||
|
</iframe>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section v-else>
|
||||||
<div class="card mb-3">
|
<div class="card mb-3">
|
||||||
<div class="card-body d-flex flex-column flex-md-row">
|
<div class="card-body d-flex flex-column flex-md-row">
|
||||||
<div class="mx-2 text-center">
|
<div class="mx-2 text-center">
|
||||||
|
@ -162,6 +174,8 @@
|
||||||
captchaToken: null,
|
captchaToken: null,
|
||||||
|
|
||||||
universalDomains: process.env.ALL_LOCALES_URLS.split(',').filter(x => x !== process.env.BASE_URL),
|
universalDomains: process.env.ALL_LOCALES_URLS.split(',').filter(x => x !== process.env.BASE_URL),
|
||||||
|
|
||||||
|
logoutInProgress: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
|
@ -242,8 +256,13 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
logout() {
|
logout() {
|
||||||
|
this.logoutInProgress = true;
|
||||||
|
setTimeout(this.doLogout, 3000);
|
||||||
|
},
|
||||||
|
doLogout() {
|
||||||
this.$store.commit('setToken', null);
|
this.$store.commit('setToken', null);
|
||||||
this.$cookies.removeAll();
|
this.$cookies.removeAll();
|
||||||
|
this.logoutInProgress = false;
|
||||||
},
|
},
|
||||||
setProfiles(profiles) {
|
setProfiles(profiles) {
|
||||||
this.profiles = profiles;
|
this.profiles = profiles;
|
||||||
|
|
|
@ -19,6 +19,7 @@ const allVersionsUrls = buildList(function*() {
|
||||||
yield 'http://pronouns.test:3000';
|
yield 'http://pronouns.test:3000';
|
||||||
yield 'http://localhost:3000';
|
yield 'http://localhost:3000';
|
||||||
} else {
|
} else {
|
||||||
|
yield 'https://pronouns.page';
|
||||||
for (let loc in locales) {
|
for (let loc in locales) {
|
||||||
yield locales[loc].url;
|
yield locales[loc].url;
|
||||||
}
|
}
|
||||||
|
|
|
@ -468,6 +468,7 @@ router.post('/user/set-avatar', handleErrorAsync(async (req, res) => {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
router.get('/user/init-universal/:token', handleErrorAsync(async (req, res) => {
|
router.get('/user/init-universal/:token', handleErrorAsync(async (req, res) => {
|
||||||
|
res.header('Access-Control-Allow-Origin', '*');
|
||||||
if (req.user) {
|
if (req.user) {
|
||||||
return res.json('Already logged in');
|
return res.json('Already logged in');
|
||||||
}
|
}
|
||||||
|
@ -476,4 +477,10 @@ router.get('/user/init-universal/:token', handleErrorAsync(async (req, res) => {
|
||||||
return res.json('Token saved');
|
return res.json('Token saved');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
router.get('/user/logout-universal', handleErrorAsync(async (req, res) => {
|
||||||
|
res.header('Access-Control-Allow-Origin', '*');
|
||||||
|
res.clearCookie('token');
|
||||||
|
return res.json('Token removed');
|
||||||
|
}));
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|
Reference in New Issue