release v2.0.0 #4

Merged
crimsen merged 481 commits from develop into master 2024-01-18 15:15:08 +00:00
3 changed files with 20 additions and 15 deletions
Showing only changes of commit e347129ba9 - Show all commits

View File

@ -27,34 +27,35 @@ export default boot(({ router }) => {
*/ */
api.interceptors.response.use( api.interceptors.response.use(
(response) => response, (response) => response,
(error) => { async (error) => {
const store = useMainStore(); const store = useMainStore();
if (error) { if (error) {
const e = <AxiosError>error; const e = <AxiosError>error;
const current = router.currentRoute.value;
if ( if (
e.code === 'ECONNABORTED' || e.code === 'ECONNABORTED' ||
(e.response && e.response.status >= 502 && e.response.status <= 504) (e.response && e.response.status >= 502 && e.response.status <= 504)
) { ) {
const current = router.currentRoute.value;
let next = current.path; let next = current.path;
if ((current.name == 'login' || current.name == 'offline') && current.query.redirect) if ((current.name == 'login' || current.name == 'offline') && current.query.redirect)
next = <string>current.query.redirect; next = <string>current.query.redirect;
return router.push({ await router.push({
name: 'offline', name: 'offline',
query: { redirect: next }, query: { redirect: next },
}); });
} else if (e.response && e.response.status == 401) { } else if (e.response && e.response.status == 401) {
if (router.currentRoute.value.name !== 'login') { void store.logout();
store.logout(); if (current.name !== 'login') {
return router.push({ await router.push({
name: 'login', name: 'login',
query: { logout: '.', redirect: router.currentRoute.value.fullPath }, params: { logout: 'logout' },
query: { redirect: current.path },
}); });
} }
} }
} }
return Promise.reject(error); throw error;
} }
); );
}); });

View File

@ -122,8 +122,7 @@ export default defineComponent({
else { else {
if (row.receiver_id == null) return 'Angeschrieben'; if (row.receiver_id == null) return 'Angeschrieben';
else { else {
if (row.receiver_id === (<FG.User>userGetters.currentUser())?.userid) if (row.receiver_id === mainStore.currentUser.userid) return 'Bekommen von X';
return 'Bekommen von X';
else return 'Gesendet an X'; else return 'Gesendet an X';
} }
} }

View File

@ -88,17 +88,22 @@ export const useMainStore = defineStore({
} }
}, },
logout() { async logout() {
if (!this.session) return false; 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({ this.$patch({
session: undefined, session: undefined,
user: undefined, user: undefined,
}); });
SessionStorage.clear(); SessionStorage.clear();
}); }
LocalStorage.remove('session');
return true; return true;
}, },