From e13446d9b3d8aa6c08f90315098d6be0a22b7c21 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Thu, 14 Jul 2022 15:06:27 +0300 Subject: [PATCH] Add GetIssuer functon on EnvironmentService --- .../core/src/lib/services/environment.service.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/npm/ng-packs/packages/core/src/lib/services/environment.service.ts b/npm/ng-packs/packages/core/src/lib/services/environment.service.ts index 9fd1e280a3..a4e74cf16a 100644 --- a/npm/ng-packs/packages/core/src/lib/services/environment.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/environment.service.ts @@ -7,6 +7,13 @@ import { InternalStore } from '../utils/internal-store-utils'; const mapToApiUrl = (key: string) => (apis: Apis) => (apis[key] || apis.default).url || apis.default.url; +const mapToIssuer = (issuer: string) => { + if (!issuer) { + return issuer; + } + return issuer.endsWith('/') ? issuer : issuer + '/'; +}; + @Injectable({ providedIn: 'root' }) export class EnvironmentService { private readonly store = new InternalStore({} as Environment); @@ -34,4 +41,13 @@ export class EnvironmentService { setState(environment: Environment) { this.store.set(environment); } + + getIssuer() { + const issuer = this.store.state.oAuthConfig.issuer; + return mapToIssuer(issuer); + } + + getIssuer$() { + return this.store.sliceState(state => state.oAuthConfig.issuer).pipe(map(mapToIssuer)); + } }