mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-18 15:57:31 -03:00
fix: no se borraban los tokens expirados
This commit is contained in:
@@ -61,7 +61,7 @@ if (browser) {
|
|||||||
const user = auth.currentUser;
|
const user = auth.currentUser;
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
const token = await user.getIdToken(true);
|
const token = await user.getIdToken();
|
||||||
currentSesion.update((s) => {
|
currentSesion.update((s) => {
|
||||||
if (s) {
|
if (s) {
|
||||||
return { ...s, accessToken: token };
|
return { ...s, accessToken: token };
|
||||||
@@ -72,6 +72,7 @@ if (browser) {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error obteniendo token de Firebase:', error);
|
console.error('Error obteniendo token de Firebase:', error);
|
||||||
|
sesionStore.reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,8 +82,14 @@ if (browser) {
|
|||||||
|
|
||||||
const expirationTime = decoded.exp * 1000;
|
const expirationTime = decoded.exp * 1000;
|
||||||
const currentTime = Date.now();
|
const currentTime = Date.now();
|
||||||
const timeUntilExpiration = expirationTime - currentTime;
|
|
||||||
|
|
||||||
|
// Si el token ya expiró, hacer reset
|
||||||
|
if (expirationTime < currentTime) {
|
||||||
|
sesionStore.reset();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const timeUntilExpiration = expirationTime - currentTime;
|
||||||
return timeUntilExpiration <= 60 * 1000; // 1 minuto
|
return timeUntilExpiration <= 60 * 1000; // 1 minuto
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -117,7 +124,7 @@ if (browser) {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error refrescando token:', error);
|
console.error('Error refrescando token:', error);
|
||||||
currentSesion.set(null);
|
sesionStore.reset();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user