Chore: Upgrade to Angular v18
Chore: Upgrade to Python 3.12 Chore: Upgrade to psycopg3
This commit is contained in:
17
bookie/src/app/core/refresh.interceptor.ts
Normal file
17
bookie/src/app/core/refresh.interceptor.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { HttpInterceptorFn } from '@angular/common/http';
|
||||
import { inject } from '@angular/core';
|
||||
|
||||
import { AuthService } from '../auth/auth.service';
|
||||
|
||||
export const refreshInterceptor: HttpInterceptorFn = (req, next) => {
|
||||
const authService = inject(AuthService);
|
||||
if (!authService.isRefreshing && authService.user && authService.needsRefreshing()) {
|
||||
authService.isRefreshing = true;
|
||||
authService.refreshToken().subscribe({
|
||||
next: () => {
|
||||
authService.isRefreshing = false;
|
||||
},
|
||||
});
|
||||
}
|
||||
return next(req);
|
||||
};
|
||||
Reference in New Issue
Block a user