Fix auth token refresh to be on first load only (#8204)

This commit is contained in:
ian
2021-09-21 22:59:05 +08:00
committed by GitHub
parent d472e2c2b6
commit c2f0e407a0

View File

@@ -62,12 +62,15 @@ export const router = createRouter({
routes: defaultRoutes,
});
let firstLoad = true;
export const onBeforeEach: NavigationGuard = async (to, from) => {
const appStore = useAppStore();
const serverStore = useServerStore();
// First load
if (from.name === undefined) {
if (firstLoad) {
firstLoad = false;
// Try retrieving a fresh access token on first load
try {
await refresh({ navigate: false });