diff --git a/src/app/graphql.module.ts b/src/app/graphql.module.ts index fd2d0f5..9b7ae36 100644 --- a/src/app/graphql.module.ts +++ b/src/app/graphql.module.ts @@ -13,18 +13,6 @@ import { DefaultOptions } from '@apollo/client/core/ApolloClient'; const uri = environment.apiUrl + '/graphql'; // <-- add the URL of the GraphQL server here -const authMiddleware = new ApolloLink((operation, forward) => { - //Add token here TODO: use AuthService to get the Token - operation.setContext({ - headers: { - authorization: localStorage.getItem('requestToken') || null, - } - }); - return forward(operation).map((data) => { - return data; - }); -}); - const defaultOptions: DefaultOptions = { watchQuery: { fetchPolicy: 'no-cache', @@ -38,7 +26,7 @@ const defaultOptions: DefaultOptions = { export function createApollo(httpLink: HttpLink): ApolloClientOptions { return { - link: concat(authMiddleware, httpLink.create({ uri })), + link: httpLink.create({ uri }), cache: new InMemoryCache({}), defaultOptions: defaultOptions, }; diff --git a/src/app/helper/token.interceptor.ts b/src/app/helper/token.interceptor.ts index 693ca02..f6bbe2e 100644 --- a/src/app/helper/token.interceptor.ts +++ b/src/app/helper/token.interceptor.ts @@ -8,7 +8,7 @@ import { catchError, filter, take, switchMap } from 'rxjs/operators'; export class TokenInterceptor implements HttpInterceptor { private isRefreshing = false; - private refreshTokenSubject: BehaviorSubject = new BehaviorSubject(null); + private requestTokenSubject: BehaviorSubject = new BehaviorSubject(null); constructor(public authService: AuthService) { } @@ -20,7 +20,6 @@ export class TokenInterceptor implements HttpInterceptor { return next.handle(request).pipe(catchError(error => { if (error instanceof HttpErrorResponse && error.status === 401) { - console.log("catching error"); return this.handle401Error(request, next); } else { return throwError(error); @@ -39,17 +38,17 @@ export class TokenInterceptor implements HttpInterceptor { private handle401Error(request: HttpRequest, next: HttpHandler) { if (!this.isRefreshing) { this.isRefreshing = true; - this.refreshTokenSubject.next(null); + this.requestTokenSubject.next(null); return this.authService.refreshToken().pipe( switchMap((token: any) => { this.isRefreshing = false; - this.refreshTokenSubject.next(token.jwt); - return next.handle(this.addToken(request, token.jwt)); + this.requestTokenSubject.next(token.request_token); + return next.handle(this.addToken(request, token.request_token)); })); } else { - return this.refreshTokenSubject.pipe( + return this.requestTokenSubject.pipe( filter(token => token != null), take(1), switchMap(jwt => { diff --git a/src/app/pages/tables/bikes/bikes.component.html b/src/app/pages/tables/bikes/bikes.component.html index cf30a16..eac2a82 100644 --- a/src/app/pages/tables/bikes/bikes.component.html +++ b/src/app/pages/tables/bikes/bikes.component.html @@ -9,10 +9,17 @@ matTooltip="Tabllendaten aktualisieren. Achtung! Alle ungespeicherten Ă„nderungen gehen verloren." (click)="reloadTable()" [disabled]="reloadingTable" - i18n > sync + Filter @@ -60,6 +67,7 @@ + @@ -85,7 +93,7 @@ -
+