add event object

This commit is contained in:
Roland Schneider
2025-11-20 15:08:32 +01:00
parent d635ba0986
commit 635975207f
27 changed files with 1224 additions and 92 deletions

View File

@@ -64,17 +64,24 @@ export class AuthService {
}
refreshToken(): Observable<any> {
console.info("getting refresh token");
const refreshToken = this.getRefreshToken();
if (!refreshToken) {
console.info("no refresh token found", refreshToken);
// If no refresh token is present, logout and return an error.
this.clientSideLogout();
return throwError(() => new Error('No refresh token available'));
}
console.info("refresh token found", refreshToken);
return this.http.post<{ accessToken: string; refreshToken: string }>(`${this.apiUrl}/refresh`, {}, {
headers: { Authorization: `Bearer ${refreshToken}` }
}).pipe(
tap((response) => this.setTokens(response.accessToken, response.refreshToken))
tap((response) => {
this.setTokens(response.accessToken, response.refreshToken);
this.decodeAndSetUser(response.accessToken);
})
);
}

View File

@@ -48,7 +48,7 @@ export class JwtInterceptor implements HttpInterceptor {
// this.refreshTokenSubject.next(null);
this.refreshTokenSubject = new BehaviorSubject<any>(null);
console.info("Refreshing tokens");
return this.authService.refreshToken().pipe(
switchMap((token: any) => {
this.refreshTokenSubject.next(token.accessToken);
@@ -60,6 +60,7 @@ export class JwtInterceptor implements HttpInterceptor {
return throwError(() => err);
}),
finalize(() => {
console.info("refreshing done")
// When the refresh attempt completes, set isRefreshing to false
this.isRefreshing = false;
})