Skip to content

Commit

Permalink
Fix: double refresh after 10sec in IAM init
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbet committed Jan 23, 2024
1 parent 3d76d29 commit 82d3b6d
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ export class ArlasIamService extends ArlasAuthentificationService {
const timeout = expires.getTime() - Date.now() - (60 * 1000);
// todo: !! attention if the token expires in less than one minute !
// refresh accessToken when timeout ended (passing the refreshToken)
// start the delay after 10 seconds
this.refreshTokenTimer$ = timer(10000, timeout).pipe(takeUntil(this.unsubscribe)).subscribe(() => {
// start the delay after 0 seconds
this.refreshTokenTimer$ = timer(0, timeout).pipe(takeUntil(this.unsubscribe)).subscribe(() => {
const newestRefreshToken = this.getRefreshToken();
this.refresh(newestRefreshToken.value).subscribe({
next: (loginData: LoginData) => {
Expand Down Expand Up @@ -186,7 +186,6 @@ export class ArlasIamService extends ArlasAuthentificationService {
this.user = loginData.user;
this.setHeadersFromAccesstoken(loginData.accessToken);
this.storeRefreshToken(loginData.refreshToken);
this.tokenRefreshedSource.next(loginData);
this.startRefreshTokenTimer(loginData);
return Promise.resolve();
})
Expand Down

0 comments on commit 82d3b6d

Please sign in to comment.