Skip to content

Commit d0a3b65

Browse files
authored
BAEL-7748: Missing test for Java Long.MAX_VALUE in angular-ui service (#18293)
1 parent c1db531 commit d0a3b65

File tree

1 file changed

+9
-4
lines changed
  • spring-security-modules/spring-security-oauth2-bff/angular-ui/src/app/auth

1 file changed

+9
-4
lines changed

spring-security-modules/spring-security-oauth2-bff/angular-ui/src/app/auth/user.service.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,16 @@ export class UserService {
6363
: User.ANONYMOUS
6464
);
6565
}
66-
if (!!user.exp) {
66+
if (typeof user.exp === "number" && user.exp > 0 && user.exp < Number.MAX_SAFE_INTEGER / 1000) {
6767
const now = Date.now();
68-
const delay = (1000 * user.exp - now) * 0.8;
69-
if (delay > 2000) {
70-
this.refreshSub = interval(delay).subscribe(() => this.refresh());
68+
const expMs = user.exp * 1000; // Convert expiration time to milliseconds safely
69+
70+
if (expMs > now) { // Ensure expiration is in the future
71+
const delay = (expMs - now) * 0.8;
72+
73+
if (delay > 2000 && delay < Number.MAX_SAFE_INTEGER) {
74+
this.refreshSub = interval(delay).subscribe(() => this.refresh());
75+
}
7176
}
7277
}
7378
},

0 commit comments

Comments
 (0)