diff --git a/interfaces/IBF-dashboard/package-lock.json b/interfaces/IBF-dashboard/package-lock.json index 9d0a03416..746a5ccf8 100644 --- a/interfaces/IBF-dashboard/package-lock.json +++ b/interfaces/IBF-dashboard/package-lock.json @@ -21,7 +21,6 @@ "@microsoft/applicationinsights-web": "^2.5.11", "@ngx-translate/core": "^16.0.4", "@ngx-translate/http-loader": "^8.0.0", - "@rollup/rollup-linux-x64-musl": "^4.30.0", "@turf/bbox": "^7.2.0", "@turf/invariant": "^7.2.0", "@turf/meta": "^7.2.0", @@ -48,9 +47,9 @@ "@angular/compiler-cli": "^19.0.5", "@angular/language-service": "^19.0.5", "@ionic/cli": "^7.2.0", - "@tailwindcss/aspect-ratio": "*", - "@tailwindcss/forms": "*", - "@tailwindcss/line-clamp": "*", + "@tailwindcss/aspect-ratio": "latest", + "@tailwindcss/forms": "latest", + "@tailwindcss/line-clamp": "latest", "@tanstack/eslint-plugin-query": "^5.61.3", "@types/jasmine": "^5.1.4", "@types/leaflet": "^1.9.12", diff --git a/interfaces/IBF-dashboard/src/app/auth/auth.service.ts b/interfaces/IBF-dashboard/src/app/auth/auth.service.ts index 4f169e126..fa6581e93 100644 --- a/interfaces/IBF-dashboard/src/app/auth/auth.service.ts +++ b/interfaces/IBF-dashboard/src/app/auth/auth.service.ts @@ -70,6 +70,11 @@ export class AuthService implements OnDestroy { return null; } + const isExpired: boolean = this.jwtService.checkExpiry(rawToken); + if (isExpired) { + return null; + } + const decodedToken = this.jwtService.decodeToken(rawToken); const user: User = { token: rawToken, diff --git a/interfaces/IBF-dashboard/src/app/services/jwt.service.ts b/interfaces/IBF-dashboard/src/app/services/jwt.service.ts index b70c92c72..a8830494c 100644 --- a/interfaces/IBF-dashboard/src/app/services/jwt.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/jwt.service.ts @@ -24,4 +24,8 @@ export class JwtService { public decodeToken(rawToken: string): any { return this.jwtHelper.decodeToken(rawToken); } + + public checkExpiry(rawToken: string): boolean { + return this.jwtHelper.isTokenExpired(rawToken); + } } diff --git a/services/API-service/src/roles.guard.ts b/services/API-service/src/roles.guard.ts index 2be104149..6a1ddb70d 100644 --- a/services/API-service/src/roles.guard.ts +++ b/services/API-service/src/roles.guard.ts @@ -23,7 +23,14 @@ export class RolesGuard implements CanActivate { const authHeaders = req.headers.authorization; if (authHeaders && (authHeaders as string).split(' ')[1]) { const token = (authHeaders as string).split(' ')[1]; - const decoded: User = jwt.verify(token, process.env.SECRET); + + let decoded: User; + try { + decoded = jwt.verify(token, process.env.SECRET); + } catch { + return false; + } + const user = await this.userService.findById(decoded.userId); // First check if logged in