Update API client and request interceptor
This commit is contained in:
@ -2,15 +2,20 @@ import {Injectable} from '@angular/core';
|
||||
import {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest,} from '@angular/common/http';
|
||||
import {Observable} from 'rxjs';
|
||||
import {AuthService} from '../services/auth.service';
|
||||
import {Router} from '@angular/router';
|
||||
|
||||
@Injectable()
|
||||
export class RequestInterceptor implements HttpInterceptor {
|
||||
constructor(private authService: AuthService) {
|
||||
constructor(private authService: AuthService, private router: Router) {
|
||||
}
|
||||
|
||||
intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
|
||||
const authToken = this.authService.getToken() || "";
|
||||
|
||||
if (authToken == "") {
|
||||
this.router.navigate(["/login"]);
|
||||
}
|
||||
|
||||
const newReq = req.clone({
|
||||
headers: req.headers.set("Authorization", `Bearer ${authToken}`),
|
||||
});
|
||||
|
17
src/gen/model/patchOperation.ts
Normal file
17
src/gen/model/patchOperation.ts
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* swisssign-challenge - dlmw
|
||||
*
|
||||
* Contact: dylan@dlmw.ch
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface PatchOperation {
|
||||
op: string;
|
||||
path: string;
|
||||
value: string;
|
||||
}
|
||||
|
Reference in New Issue
Block a user