source: Farmatiko/ClientApp/src/app/shared/core.module.ts@ 472dd7e

Last change on this file since 472dd7e was 1f4846d, checked in by Mile Jankuloski <mile.jankuloski@…>, 4 years ago

Jwt token auth interceptors, services and guards

  • Property mode set to 100644
File size: 1023 bytes
Line 
1import { NgModule, APP_INITIALIZER, Optional, SkipSelf } from '@angular/core';
2import { CommonModule } from '@angular/common';
3import { HTTP_INTERCEPTORS } from '@angular/common/http';
4import { AuthService } from './services/auth.service';
5import { appInitializer } from './services/app-initializer';
6import { JwtInterceptor } from './interceptors/jwt.interceptor';
7import { UnauthorizedInterceptor } from './interceptors/unauthorized.interceptor';
8
9@NgModule({
10 declarations: [],
11 imports: [CommonModule],
12 providers: [
13 {
14 provide: APP_INITIALIZER,
15 useFactory: appInitializer,
16 multi: true,
17 deps: [AuthService],
18 },
19 { provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
20 {
21 provide: HTTP_INTERCEPTORS,
22 useClass: UnauthorizedInterceptor,
23 multi: true,
24 },
25 ],
26})
27export class CoreModule {
28 constructor(@Optional() @SkipSelf() core: CoreModule) {
29 if (core) {
30 throw new Error('Core Module can only be imported to AppModule.');
31 }
32 }
33}
Note: See TracBrowser for help on using the repository browser.