Merge branch 'develop' into seperate_plugins
This commit is contained in:
commit
1802081ad2
|
@ -75,19 +75,13 @@ export const useMainStore = defineStore({
|
||||||
async logout() {
|
async logout() {
|
||||||
if (!this.session || !this.session.token) return false;
|
if (!this.session || !this.session.token) return false;
|
||||||
|
|
||||||
LocalStorage.clear();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const token = this.session.token;
|
const token = this.session.token;
|
||||||
this.$patch({
|
|
||||||
session: undefined,
|
|
||||||
user: undefined,
|
|
||||||
});
|
|
||||||
await api.delete(`/auth/${token}`);
|
await api.delete(`/auth/${token}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
SessionStorage.clear();
|
this.handleLoggedOut( );
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
@ -151,6 +145,15 @@ export const useMainStore = defineStore({
|
||||||
async setShortcuts() {
|
async setShortcuts() {
|
||||||
await api.put(`users/${this.currentUser.userid}/shortcuts`, this.shortcuts);
|
await api.put(`users/${this.currentUser.userid}/shortcuts`, this.shortcuts);
|
||||||
},
|
},
|
||||||
|
handleLoggedOut() {
|
||||||
|
LocalStorage.clear();
|
||||||
|
|
||||||
|
this.$patch({
|
||||||
|
session: undefined,
|
||||||
|
user: undefined,
|
||||||
|
});
|
||||||
|
SessionStorage.clear();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ export default boot(({ router }) => {
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Intercept responses
|
* Intercept responses
|
||||||
* - filter 401 --> logout
|
* - filter 401 --> handleLoggedOut
|
||||||
* - filter timeout or 502-504 --> backendOffline
|
* - filter timeout or 502-504 --> backendOffline
|
||||||
*/
|
*/
|
||||||
api.interceptors.response.use(
|
api.interceptors.response.use(
|
||||||
|
@ -43,7 +43,7 @@ export default boot(({ router }) => {
|
||||||
query: { redirect: next },
|
query: { redirect: next },
|
||||||
});
|
});
|
||||||
} else if (e.response && e.response.status == 401) {
|
} else if (e.response && e.response.status == 401) {
|
||||||
void store.logout();
|
void store.handleLoggedOut();
|
||||||
if (current.name !== 'login') {
|
if (current.name !== 'login') {
|
||||||
await router.push({
|
await router.push({
|
||||||
name: 'login',
|
name: 'login',
|
||||||
|
|
|
@ -12,7 +12,7 @@ export default boot(({ router }) => {
|
||||||
// Secured area (LOGIN REQUIRED)
|
// Secured area (LOGIN REQUIRED)
|
||||||
// Check login is ok
|
// Check login is ok
|
||||||
if (!store.session || store.session.expires <= new Date()) {
|
if (!store.session || store.session.expires <= new Date()) {
|
||||||
void store.logout();
|
void store.handleLoggedOut();
|
||||||
return next({ name: 'login', query: { redirect: to.fullPath } });
|
return next({ name: 'login', query: { redirect: to.fullPath } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue