mirror of
https://git.mirrors.martin98.com/https://github.com/open-webui/open-webui
synced 2025-08-18 05:25:53 +08:00
refac
This commit is contained in:
parent
28ec3069de
commit
0b5514f376
@ -34,7 +34,7 @@
|
|||||||
import { Toaster, toast } from 'svelte-sonner';
|
import { Toaster, toast } from 'svelte-sonner';
|
||||||
|
|
||||||
import { executeToolServer, getBackendConfig } from '$lib/apis';
|
import { executeToolServer, getBackendConfig } from '$lib/apis';
|
||||||
import { getSessionUser } from '$lib/apis/auths';
|
import { getSessionUser, userSignOut } from '$lib/apis/auths';
|
||||||
|
|
||||||
import '../tailwind.css';
|
import '../tailwind.css';
|
||||||
import '../app.css';
|
import '../app.css';
|
||||||
@ -444,7 +444,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkTokenExpiry = () => {
|
const checkTokenExpiry = async () => {
|
||||||
const exp = $user?.expires_at; // token expiry time in unix timestamp
|
const exp = $user?.expires_at; // token expiry time in unix timestamp
|
||||||
const now = Math.floor(Date.now() / 1000); // current time in unix timestamp
|
const now = Math.floor(Date.now() / 1000); // current time in unix timestamp
|
||||||
|
|
||||||
@ -454,11 +454,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (now >= exp) {
|
if (now >= exp) {
|
||||||
|
await userSignOut();
|
||||||
|
user.set(null);
|
||||||
|
|
||||||
localStorage.removeItem('token');
|
localStorage.removeItem('token');
|
||||||
// redirect to auth page
|
location.href = '/auth';
|
||||||
if ($page.url.pathname !== '/auth') {
|
|
||||||
goto(`/auth`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user