libs/oauth/src/lib/oauth.module.ts
Static forRoot | ||||||
forRoot(options: OauthOptions)
|
||||||
Defined in libs/oauth/src/lib/oauth.module.ts:26
|
||||||
Parameters :
Returns :
ModuleWithProviders<OauthModule>
|
import { CommonModule } from '@angular/common';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { ModuleWithProviders, NgModule } from '@angular/core';
import { OauthInterceptor } from './interceptor/oauth.interceptor';
import { OauthService } from './oauth.service';
import { OAUTH_CONFIGURATIONS, OauthOptions } from './symbols';
@NgModule({
imports: [CommonModule],
providers: [
OauthService,
OauthInterceptor,
{
provide: HTTP_INTERCEPTORS,
useClass: OauthInterceptor,
multi: true
}
]
})
export class OauthModule {
// This injection of OauthService is needed to make sure the service is instantiated early enough in manual apps.
// Otherwise the subscription to the Router events happens after the "RoutesRecognized" event
// and the oauth configurations are not set in the service
constructor(private oauthService: OauthService) {}
static forRoot(options: OauthOptions): ModuleWithProviders<OauthModule> {
return {
ngModule: OauthModule,
providers: [
{
provide: OAUTH_CONFIGURATIONS,
useValue: options.configurations
}
]
};
}
}