fixed load env config
This commit is contained in:
parent
40a6d188dd
commit
fec59d6e21
@ -8,6 +8,18 @@ import { BASE_HREF } from '../../tokens';
|
||||
import { environment } from '@environments/environment';
|
||||
|
||||
export function keycloakInitializer(keycloakService: KeycloakService, configService: ConfigService, baseUrl: string): () => Promise<void> {
|
||||
return () =>
|
||||
configService
|
||||
.loadAppConfig()
|
||||
.toPromise()
|
||||
.then(() =>
|
||||
keycloakService
|
||||
.init(getKeycloakOptions(configService, baseUrl))
|
||||
.then(() => configureAutomaticRedirectToLoginScreen(keycloakService))
|
||||
);
|
||||
}
|
||||
|
||||
function getKeycloakOptions(configService: ConfigService, baseUrl: string) {
|
||||
let url = configService.values.OAUTH_URL;
|
||||
url = url.replace(/\/$/, ''); // remove trailing slash
|
||||
const realm = url.substring(url.lastIndexOf('/') + 1, url.length);
|
||||
@ -28,7 +40,7 @@ export function keycloakInitializer(keycloakService: KeycloakService, configServ
|
||||
},
|
||||
enableBearerInterceptor: true
|
||||
};
|
||||
return () => keycloakService.init(options).then(() => configureAutomaticRedirectToLoginScreen(keycloakService));
|
||||
return options;
|
||||
}
|
||||
|
||||
function configureAutomaticRedirectToLoginScreen(keyCloakService: KeycloakService) {
|
||||
|
||||
@ -4,6 +4,8 @@ import { Title } from '@angular/platform-browser';
|
||||
import packageInfo from '../../../../../package.json';
|
||||
import config from '../../assets/config/config.json';
|
||||
import { CacheApiService, wipeCaches } from '@redaction/red-cache';
|
||||
import { Observable } from 'rxjs';
|
||||
import { tap } from 'rxjs/operators';
|
||||
|
||||
const version = packageInfo.version;
|
||||
|
||||
@ -21,6 +23,15 @@ export class ConfigService {
|
||||
this._checkFrontendVersion();
|
||||
}
|
||||
|
||||
loadAppConfig(): Observable<any> {
|
||||
return this._httpClient.get<any>('/assets/config/config.json').pipe(
|
||||
tap(envConfig => {
|
||||
console.log('[REDACTION] Started with config: ', envConfig);
|
||||
this._values = envConfig;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private _checkFrontendVersion(): void {
|
||||
this._cacheApiService.getCachedValue('FRONTEND_APP_VERSION').then(async lastVersion => {
|
||||
console.log('[REDACTION] Last app version: ', lastVersion, ' current version ', version);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user