Options
All
  • Public
  • Public/Protected
  • All
Menu

Gets and sets configuration for the internal Authok client. This can be used to provide configuration outside of using AuthModule.forRoot, i.e. from a factory provided by APP_INITIALIZER.

usage
// app.module.ts
// ---------------------------
import { AuthModule, AuthClientConfig } from '@authok/authok-angular';

// Provide an initializer function that returns a Promise
function configInitializer(
  http: HttpClient,
  config: AuthClientConfig
) {
  return () =>
    http
      .get('/config')
      .toPromise()
      .then((loadedConfig: any) => config.set(loadedConfig));   // Set the config that was loaded asynchronously here
}

// Provide APP_INITIALIZER with this function. Note that there is no config passed to AuthModule.forRoot
imports: [
  // other imports..

  HttpClientModule,
  AuthModule.forRoot(),   //<- don't pass any config here
],
providers: [
  {
    provide: APP_INITIALIZER,
    useFactory: configInitializer,    // <- pass your initializer function here
    deps: [HttpClient, AuthClientConfig],
    multi: true,
  },
],

Hierarchy

  • AuthClientConfig

Index

Constructors

Methods

Constructors

constructor

Methods

get

set

  • Sets configuration to be read by other consumers of the service (see usage notes)

    Parameters

    Returns void