Browse Source

feat(client): replace constructor based DI with inject functions

pull/6957/head
KenTandrian 3 months ago
parent
commit
ee797530a9
  1. 12
      apps/client/src/app/core/auth.guard.ts
  2. 16
      apps/client/src/app/core/auth.interceptor.ts

12
apps/client/src/app/core/auth.guard.ts

@ -3,7 +3,7 @@ import { UserService } from '@ghostfolio/client/services/user/user.service';
import { internalRoutes, publicRoutes } from '@ghostfolio/common/routes/routes';
import { DataService } from '@ghostfolio/ui/services';
import { Injectable } from '@angular/core';
import { inject, Injectable } from '@angular/core';
import {
ActivatedRouteSnapshot,
Router,
@ -14,12 +14,10 @@ import { catchError } from 'rxjs/operators';
@Injectable({ providedIn: 'root' })
export class AuthGuard {
public constructor(
private dataService: DataService,
private router: Router,
private settingsStorageService: SettingsStorageService,
private userService: UserService
) {}
private readonly dataService = inject(DataService);
private readonly router = inject(Router);
private readonly settingsStorageService = inject(SettingsStorageService);
private readonly userService = inject(UserService);
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
const utmSource = route.queryParams?.utm_source;

16
apps/client/src/app/core/auth.interceptor.ts

@ -13,20 +13,20 @@ import {
HttpInterceptor,
HttpRequest
} from '@angular/common/http';
import { Injectable } from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { Observable } from 'rxjs';
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
public constructor(
private impersonationStorageService: ImpersonationStorageService,
private tokenStorageService: TokenStorageService
) {}
private readonly impersonationStorageService = inject(
ImpersonationStorageService
);
private readonly tokenStorageService = inject(TokenStorageService);
public intercept(
req: HttpRequest<any>,
public intercept<T>(
req: HttpRequest<T>,
next: HttpHandler
): Observable<HttpEvent<any>> {
): Observable<HttpEvent<T>> {
let request = req;
if (request.headers.has(HEADER_KEY_SKIP_INTERCEPTOR)) {

Loading…
Cancel
Save