KEYCLOAK-11496 detect session timeout
This commit is contained in:
parent
3eedcdb154
commit
af0f43b769
2 changed files with 34 additions and 32 deletions
|
@ -62,7 +62,6 @@ public class SessionTest extends AbstractAccountTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void reactPageSsoTimeoutTest() {
|
||||
deviceActivityPage.navigateToUsingSidebar();
|
||||
deviceActivityPage.assertCurrent();
|
||||
|
@ -75,7 +74,6 @@ public class SessionTest extends AbstractAccountTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void reactPageAsyncLogoutTest() {
|
||||
testRealmResource().logoutAll();
|
||||
deviceActivityPage.navigateToUsingSidebar();
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
//import {KeycloakNotificationService} from '../notification/keycloak-notification.service';
|
||||
import {KeycloakService} from '../keycloak-service/keycloak.service';
|
||||
import Axios, {AxiosRequestConfig, AxiosResponse} from 'axios';
|
||||
import Axios, {AxiosRequestConfig, AxiosResponse, AxiosError} from 'axios';
|
||||
import {ContentAlert} from '../content/ContentAlert';
|
||||
|
||||
//import {NotificationType} from 'patternfly-ng/notification';*/
|
||||
|
@ -74,7 +74,7 @@ export class AccountServiceClient {
|
|||
.then((config: AxiosRequestConfig) => {
|
||||
console.log({config});
|
||||
this.axiosRequest(config, resolve, reject);
|
||||
}).catch( (error: Error) => {
|
||||
}).catch( (error: AxiosError) => {
|
||||
this.handleError(error);
|
||||
reject(error);
|
||||
});
|
||||
|
@ -88,13 +88,17 @@ export class AccountServiceClient {
|
|||
.then((response: AxiosResponse) => {
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error: Error) => {
|
||||
.catch((error: AxiosError) => {
|
||||
this.handleError(error);
|
||||
reject(error);
|
||||
});
|
||||
}
|
||||
|
||||
private handleError(error: Error): void {
|
||||
private handleError(error: AxiosError): void {
|
||||
if (error != null && error.response != null && error.response.status === 401) {
|
||||
// session timed out?
|
||||
this.kcSvc.login();
|
||||
}
|
||||
console.log(error);
|
||||
ContentAlert.danger(error.name + ': ' + error.message);
|
||||
}
|
||||
|
@ -109,8 +113,8 @@ export class AccountServiceClient {
|
|||
url: endpoint,
|
||||
headers: {...config.headers, Authorization: 'Bearer ' + token}
|
||||
});
|
||||
}).catch((error: Error) => {
|
||||
reject(error);
|
||||
}).catch(() => {
|
||||
this.kcSvc.login();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue