forgot stuff

This commit is contained in:
Rene Kievits
2025-10-27 06:10:53 +01:00
parent 150667f781
commit 96458b9e94
2 changed files with 5 additions and 7 deletions

View File

@@ -34,7 +34,6 @@ export const useAuthStore = defineStore('auth', () => {
return true
}
// Token expired or invalid → try refresh
if (res.status === 401) {
const refreshed = await refreshToken()
if (refreshed) return await fetchUser()
@@ -88,7 +87,6 @@ export const useAuthStore = defineStore('auth', () => {
* Refresh the access token using refresh cookie.
*/
async function refreshToken() {
// Skip if no refresh cookie (expired or logged out)
if (!document.cookie.includes('refresh_token')) return false
try {
@@ -116,7 +114,6 @@ export const useAuthStore = defineStore('auth', () => {
function startAutoRefresh() {
if (refreshInterval) clearInterval(refreshInterval)
// Refresh every 7.5 minutes (half of 15m access token)
refreshInterval = setInterval(async () => {
if (!user.value) return
const success = await refreshToken()
@@ -130,7 +127,6 @@ export const useAuthStore = defineStore('auth', () => {
}
}, 7.5 * 60 * 1000)
// Also refresh immediately if tab comes back from background
document.addEventListener('visibilitychange', async () => {
if (document.visibilityState === 'visible' && user.value) {
const success = await refreshToken()