How to use the @nebular/auth.NbOAuth2ResponseType.CODE function in @nebular/auth

To help you get started, we’ve selected a few @nebular/auth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github akveo / nebular / src / playground / without-layout / azure / azure-adb2c-auth-strategy.ts View on Github external
getValue(): string {
    return this.token.id_token;
  }
}

@Injectable()
export class AzureADB2CAuthStrategy extends NbOAuth2AuthStrategy {

  // we need this method for strategy setup
  static setup(options: NbOAuth2AuthStrategyOptions): [NbAuthStrategyClass, NbOAuth2AuthStrategyOptions] {
    return [AzureADB2CAuthStrategy, options];
  }

  protected redirectResultHandlers = {
    [NbOAuth2ResponseType.CODE]: () => {
      return of(this.route.snapshot.queryParams).pipe(
        switchMap((params: any) => {
          if (params.code) {
            return this.requestToken(params.code);
          }

          return of(
            new NbAuthResult(
              false,
              params,
              this.getOption('redirect.failure'),
              this.getOption('defaultErrors'),
              [],
            ));
        }),
      );
github akveo / nebular / 3.6.2 / assets / examples / azure / azure-adb2c-auth-strategy.ts View on Github external
}
          return of(
            new NbAuthResult(
              false,
              err,
              this.getOption('redirect.failure'),
              errors,
            ));
        }),
      );
    },
  };


  protected redirectResults: any = {
    [NbOAuth2ResponseType.CODE]: () => of(null),

    id_token: () => {
      return of(this.route.snapshot.fragment).pipe(
        map(fragment => this.parseHashAsQueryParams(fragment)),
        map((params: any) => !!(params && (params.id_token || params.error))),
      );
    },
  };
}