diff --git a/src/app/app.module.ts b/src/app/app.module.ts index cf9faf2c888110517e48fac164edba53c4c1010c..8e3cb812c8876e83d1ad579ff2d88fe707a29731 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,7 +1,7 @@ import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { NgModule, APP_INITIALIZER } from '@angular/core'; -import { HttpClientModule } from '@angular/common/http'; +import { HttpClientModule, HttpClientXsrfModule } from '@angular/common/http'; import { AppComponent } from './app.component'; import { AppRoutingModule } from './app-routing.module'; @@ -44,6 +44,9 @@ export function initAppConfig(appConfigService: AppConfigService) { BrowserModule, BrowserAnimationsModule, HttpClientModule, + HttpClientXsrfModule.withOptions({ + headerName: 'x-xsrf-token', + }), CoreModule, EditorialisationModule, UserModule, diff --git a/src/app/user/interceptors/auth-interceptor.ts b/src/app/user/interceptors/auth-interceptor.ts deleted file mode 100644 index 2f8f113eaf85d5183915cb387743d1faed7300e5..0000000000000000000000000000000000000000 --- a/src/app/user/interceptors/auth-interceptor.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; - -@Injectable() -export class AuthInterceptor implements HttpInterceptor { - - intercept( - req: HttpRequest<any>, - next: HttpHandler, - ): Observable<HttpEvent<any>> { - const xsrfToken = localStorage.getItem('xsrfToken'); - let request = req; - - // && req.url.includes('https://data-intothesky.alpha.grandlyon.com/authentication/api/logout' - if (xsrfToken) { - request = req.clone({ - headers: req.headers.set('x-xsrf-token', xsrfToken), - }); - } - return next.handle(request); - } -} diff --git a/src/app/user/user.module.ts b/src/app/user/user.module.ts index 9d98bd964dbc564cb191a0025f62b48c88d0adb4..42ee8630efec09c69fe29ee1ce14dc572288097e 100644 --- a/src/app/user/user.module.ts +++ b/src/app/user/user.module.ts @@ -4,8 +4,6 @@ import { UserRoutingModule } from './user-routing.module'; import { UserServices } from './services'; import { UserComponents } from './components'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { HTTP_INTERCEPTORS } from '@angular/common/http'; -import { AuthInterceptor } from './interceptors/auth-interceptor'; import { UserGuards } from './guards'; import { SharedModule } from '../shared/shared.module'; @@ -20,11 +18,6 @@ import { SharedModule } from '../shared/shared.module'; providers: [ ...UserGuards, ...UserServices, - { - provide: HTTP_INTERCEPTORS, - useClass: AuthInterceptor, - multi: true, - }, ], declarations: [...UserComponents], })