feat: prevent api calls when user is not logged in

This commit is contained in:
Zamitto 2024-07-01 15:48:52 -03:00
parent 9870213fff
commit dd23358a95
11 changed files with 39 additions and 43 deletions

View file

@ -127,14 +127,12 @@ export class HydraApi {
}
private static async revalidateAccessTokenIfExpired() {
if (!this.userAuth.authToken) {
userAuthRepository.delete({ id: 1 });
logger.error("user is not logged in");
this.sendSignOutEvent();
if (!this.isLoggedIn()) {
throw new Error("user is not logged in");
}
const now = new Date();
if (this.userAuth.expirationTimestamp < now.getTime()) {
try {
const response = await this.instance.post(`/auth/refresh`, {