Browse Source
Merge pull request #13314 from abpframework/issue/10947
Add GetIssuer functon on EnvironmentService
pull/13269/head
Muhammed Altuğ
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
16 additions and
0 deletions
-
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)); |
|
|
|
} |
|
|
|
} |
|
|
|
|