Pull request #20: login url test

Merge in SL/common-ui from login-link-test to master

* commit 'a147ba5b8d1d0613c5b667275bd5e30f13115eb4':
  login url test
This commit is contained in:
Timo Bejan 2022-08-16 11:59:49 +02:00
commit b42baa37fc
4 changed files with 17 additions and 6 deletions

View File

@ -56,7 +56,11 @@ export class ServerErrorInterceptor implements HttpInterceptor {
catchError((error: HttpErrorResponse) => {
// token expired
if (error.status === HttpStatusCode.Unauthorized) {
this._keycloakService.logout();
const url = this._keycloakService.getKeycloakInstance().createLoginUrl({
loginHint: 'login',
redirectUri: window.location.href,
});
window.location.href = url;
}
// server error

View File

@ -15,6 +15,9 @@ export class ErrorMessageService {
}
private _parseErrorResponse(err: HttpErrorResponse): string {
return (err?.error?.message?.match('"message":"(.*?)\\"')?.[0].replace(/"message":"|"/gm, '') as string) || (err?.error?.message as string);
return (
(err?.error?.message?.match('"message":"(.*?)\\"')?.[0].replace(/"message":"|"/gm, '') as string) ||
(err?.error?.message as string)
);
}
}

View File

@ -41,11 +41,10 @@ function getKeycloakOptions(baseUrl: string, configService: IqserConfigService):
function configureAutomaticRedirectToLoginScreen(keyCloakService: KeycloakService) {
keyCloakService.getKeycloakInstance().onAuthRefreshError = () => {
const url = keyCloakService.getKeycloakInstance().createLoginUrl({
loginHint:'login',
const url = keyCloakService.getKeycloakInstance().createLoginUrl({
loginHint: 'login',
redirectUri: window.location.href,
});
console.log('creating login url',url)
window.location.href = url;
};
}

View File

@ -51,7 +51,12 @@ export abstract class IqserUserService<
async logout() {
await this._cacheApiService.wipeCaches();
await this._keycloakService.logout(window.location.origin + this._baseHref);
await this._keycloakService.logout();
const url = this._keycloakService.getKeycloakInstance().createLoginUrl({
loginHint: 'login',
redirectUri: window.location.origin + this._baseHref,
});
window.location.href = url;
}
loadAll() {