forgot stuff
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user