Last change
on this file since d23bf72 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 | |
---|
1 | import { NgModule, APP_INITIALIZER, Optional, SkipSelf } from '@angular/core';
|
---|
2 | import { CommonModule } from '@angular/common';
|
---|
3 | import { HTTP_INTERCEPTORS } from '@angular/common/http';
|
---|
4 | import { AuthService } from './services/auth.service';
|
---|
5 | import { appInitializer } from './services/app-initializer';
|
---|
6 | import { JwtInterceptor } from './interceptors/jwt.interceptor';
|
---|
7 | import { 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 | })
|
---|
27 | export 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.