fix token refresh on window focus, deactivate webkit playwright tests

This commit is contained in:
Gregor Vostrak
2024-06-24 17:18:08 +02:00
parent 237b3832bb
commit a10d0569af
4 changed files with 26 additions and 17 deletions

View File

@@ -5,6 +5,7 @@ import type {
ZodiosQueryParamsByAlias,
} from '@zodios/core';
import { api } from '../../../openapi.json.client';
import { router } from '@inertiajs/vue3';
export type SolidTimeApi = ApiOf<typeof api>;
@@ -123,3 +124,16 @@ export type UpdateOrganizationBody = ZodiosBodyByAlias<
SolidTimeApi,
'updateOrganization'
>;
export async function fetchToken() {
return new Promise((resolve) => {
router.reload({
onFinish: () => {
resolve(null);
},
});
});
}
export function isTokenValid() {
return window.document.cookie.includes('solidtime_session');
}

View File

@@ -2,6 +2,7 @@ import { defineStore } from 'pinia';
import { ref } from 'vue';
import axios from 'axios';
import { router } from '@inertiajs/vue3';
import { fetchToken } from '@/utils/api';
export type NotificationType = 'success' | 'error';
@@ -37,16 +38,6 @@ export const useNotificationsStore = defineStore('notifications', () => {
}
}
async function fetchToken() {
return new Promise((resolve) => {
router.reload({
onFinish: () => {
resolve(null);
},
});
});
}
async function handleApiRequestNotifications<T>(
apiRequest: () => Promise<T>,
successMessage?: string,