-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
90 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { provideHttpClient, withInterceptors } from '@angular/common/http'; | ||
import { ApplicationConfig, importProvidersFrom } from "@angular/core"; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { provideAnimations } from '@angular/platform-browser/animations'; | ||
import { provideRouter } from '@angular/router'; | ||
import { provideAuth } from 'angular-auth-oidc-client'; | ||
import { ToastModule } from 'primeng/toast'; | ||
import { APP_ROUTES } from './app.routes'; | ||
import { AUTH_CONFIG } from './configs'; | ||
import { tenantInterceptor, tokenInterceptor } from './core/interceptors'; | ||
|
||
export const appConfig: ApplicationConfig = { | ||
providers: [ | ||
provideAuth({config: AUTH_CONFIG}), | ||
provideRouter(APP_ROUTES), | ||
importProvidersFrom(BrowserModule, ToastModule), | ||
provideAnimations(), | ||
provideHttpClient(withInterceptors([tenantInterceptor, tokenInterceptor])), | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
src/Client/Logistics.OfficeApp/src/app/configs/app.config.ts
This file was deleted.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
src/Client/Logistics.OfficeApp/src/app/configs/auth.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Client/Logistics.OfficeApp/src/app/configs/global.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export {AuthConfig} from "./auth.config"; | ||
export {AppConfig} from "./app.config"; | ||
export * from "./auth.config"; | ||
export * from "./global.config"; |
40 changes: 0 additions & 40 deletions
40
src/Client/Logistics.OfficeApp/src/app/core/core.module.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export {AuthGuard} from "./auth.guard"; | ||
export * from "./auth.guard"; |
4 changes: 2 additions & 2 deletions
4
src/Client/Logistics.OfficeApp/src/app/core/interceptors/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export {TenantInterceptor} from "./tenant.interceptor"; | ||
export {TokenInterceptor} from "./token.interceptor"; | ||
export * from "./tenant.interceptor"; | ||
export * from "./token.interceptor"; |
26 changes: 11 additions & 15 deletions
26
src/Client/Logistics.OfficeApp/src/app/core/interceptors/tenant.interceptor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
import {Injectable} from "@angular/core"; | ||
import {HttpRequest, HttpHandler, HttpEvent, HttpInterceptor} from "@angular/common/http"; | ||
import {inject} from "@angular/core"; | ||
import {HttpRequest, HttpEvent, HttpHandlerFn} from "@angular/common/http"; | ||
import {Observable} from "rxjs"; | ||
import {TenantService} from "../services/tenant.service"; | ||
|
||
@Injectable() | ||
export class TenantInterceptor implements HttpInterceptor { | ||
constructor(private tenantService: TenantService) {} | ||
export function tenantInterceptor(request: HttpRequest<unknown>, next: HttpHandlerFn): Observable<HttpEvent<unknown>> { | ||
const tenantService = inject(TenantService); | ||
const tenantId = tenantService.getTenantName(); | ||
const headers = tenantService.createTenantHeaders(request.headers, tenantId); | ||
tenantService.setTenantCookie(tenantId); | ||
|
||
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> { | ||
const tenantId = this.tenantService.getTenantName(); | ||
const headers = this.tenantService.createTenantHeaders(request.headers, tenantId); | ||
this.tenantService.setTenantCookie(tenantId); | ||
|
||
request = request.clone({ | ||
headers: headers, | ||
}); | ||
return next.handle(request); | ||
} | ||
request = request.clone({ | ||
headers: headers, | ||
}); | ||
return next(request); | ||
} |
33 changes: 14 additions & 19 deletions
33
src/Client/Logistics.OfficeApp/src/app/core/interceptors/token.interceptor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,20 @@ | ||
import {Injectable} from "@angular/core"; | ||
import {HttpRequest, HttpHandler, HttpEvent, HttpInterceptor} from "@angular/common/http"; | ||
import {inject} from "@angular/core"; | ||
import {HttpRequest, HttpEvent, HttpHandlerFn} from "@angular/common/http"; | ||
import {Observable} from "rxjs"; | ||
import {AuthService} from "@/core/auth"; | ||
|
||
@Injectable() | ||
export class TokenInterceptor implements HttpInterceptor { | ||
constructor(private authService: AuthService) {} | ||
export function tokenInterceptor(request: HttpRequest<unknown>, next: HttpHandlerFn): Observable<HttpEvent<unknown>> { | ||
const authService = inject(AuthService); | ||
let token = ""; | ||
authService.getAccessToken().subscribe((i) => (token = i)); | ||
const headers = {Authorization: ""}; | ||
|
||
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> { | ||
let token = ""; | ||
this.authService.getAccessToken().subscribe((i) => (token = i)); | ||
const headers = {Authorization: ""}; | ||
|
||
if (!request.headers.get("bypassAuthorization")) { | ||
headers["Authorization"] = `Bearer ${token}`; | ||
} | ||
|
||
const newRequest = request.clone({ | ||
setHeaders: headers, | ||
}); | ||
|
||
return next.handle(newRequest); | ||
if (!request.headers.get("bypassAuthorization")) { | ||
headers["Authorization"] = `Bearer ${token}`; | ||
} | ||
|
||
const newRequest = request.clone({ | ||
setHeaders: headers, | ||
}); | ||
return next(newRequest); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Client/Logistics.OfficeApp/src/app/core/services/cookie.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Client/Logistics.OfficeApp/src/app/core/services/storage.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Client/Logistics.OfficeApp/src/app/core/services/toast.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.