release v2.0.0 #4
|
@ -27,34 +27,35 @@ export default boot(({ router }) => {
|
|||
*/
|
||||
api.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error) => {
|
||||
async (error) => {
|
||||
const store = useMainStore();
|
||||
|
||||
if (error) {
|
||||
const e = <AxiosError>error;
|
||||
const current = router.currentRoute.value;
|
||||
if (
|
||||
e.code === 'ECONNABORTED' ||
|
||||
(e.response && e.response.status >= 502 && e.response.status <= 504)
|
||||
) {
|
||||
const current = router.currentRoute.value;
|
||||
let next = current.path;
|
||||
if ((current.name == 'login' || current.name == 'offline') && current.query.redirect)
|
||||
next = <string>current.query.redirect;
|
||||
return router.push({
|
||||
await router.push({
|
||||
name: 'offline',
|
||||
query: { redirect: next },
|
||||
});
|
||||
} else if (e.response && e.response.status == 401) {
|
||||
if (router.currentRoute.value.name !== 'login') {
|
||||
store.logout();
|
||||
return router.push({
|
||||
void store.logout();
|
||||
if (current.name !== 'login') {
|
||||
await router.push({
|
||||
name: 'login',
|
||||
query: { logout: '.', redirect: router.currentRoute.value.fullPath },
|
||||
params: { logout: 'logout' },
|
||||
query: { redirect: current.path },
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return Promise.reject(error);
|
||||
throw error;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -122,8 +122,7 @@ export default defineComponent({
|
|||
else {
|
||||
if (row.receiver_id == null) return 'Angeschrieben';
|
||||
else {
|
||||
if (row.receiver_id === (<FG.User>userGetters.currentUser())?.userid)
|
||||
return 'Bekommen von X';
|
||||
if (row.receiver_id === mainStore.currentUser.userid) return 'Bekommen von X';
|
||||
else return 'Gesendet an X';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,17 +88,22 @@ export const useMainStore = defineStore({
|
|||
}
|
||||
},
|
||||
|
||||
logout() {
|
||||
if (!this.session) return false;
|
||||
async logout() {
|
||||
if (!this.session || !this.session.token) return false;
|
||||
|
||||
void api.delete(`/auth/${this.session.token}`).finally(() => {
|
||||
LocalStorage.clear();
|
||||
|
||||
try {
|
||||
await api.delete(`/auth/${this.session.token}`);
|
||||
} catch (error) {
|
||||
return false;
|
||||
} finally {
|
||||
this.$patch({
|
||||
session: undefined,
|
||||
user: undefined,
|
||||
});
|
||||
SessionStorage.clear();
|
||||
});
|
||||
LocalStorage.remove('session');
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue