feat: try refreshing if error not related to 401 or 403 error
This commit is contained in:
parent
60d306f9c9
commit
8a584fd28a
@ -33,10 +33,25 @@ export class TokenRefreshService {
|
|||||||
|
|
||||||
this.authService.refreshToken()
|
this.authService.refreshToken()
|
||||||
.pipe(
|
.pipe(
|
||||||
catchError(_ => {
|
catchError(error => {
|
||||||
|
if (error.status === 403 || error.status === 401) {
|
||||||
localStorage.removeItem(ApiService.tokenKey);
|
localStorage.removeItem(ApiService.tokenKey);
|
||||||
this.refreshTokenExpireMs = -1;
|
this.refreshTokenExpireMs = -1;
|
||||||
return of(undefined);
|
return of(undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
let retryTime = this.refreshTokenExpireMs;
|
||||||
|
|
||||||
|
if (retryTime < environment.retryDelay)
|
||||||
|
retryTime = environment.retryDelay;
|
||||||
|
|
||||||
|
// 15 minutes
|
||||||
|
if (retryTime * 2 <= 900_000)
|
||||||
|
retryTime *= 2;
|
||||||
|
else
|
||||||
|
retryTime = 900_000;
|
||||||
|
|
||||||
|
return of(retryTime);
|
||||||
}))
|
}))
|
||||||
.subscribe(data => {
|
.subscribe(data => {
|
||||||
if (data)
|
if (data)
|
||||||
|
Loading…
Reference in New Issue
Block a user