dependencies Legend  Declarations  Module  Bootstrap  Providers  Exports cluster_OauthModule cluster_OauthModule_providers OauthInterceptor OauthInterceptor OauthModule OauthModule OauthInterceptor->OauthModule OauthInterceptor->OauthModule OauthService OauthService OauthService->OauthModule

File

libs/oauth/src/lib/oauth.module.ts

Methods

Static forRoot
forRoot(options: OauthOptions)
Parameters :
Name Type Optional
options OauthOptions No
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
        }
      ]
    };
  }
}

results matching ""

    No results matching ""