LOGIN: {},
LOGOUT: ofType<{ deleteLinkData: boolean }>(),
SET_CONFIG: ofType<{ config: Config }>(),
- SET_EXTRA_TOKEN: ofType<{ extraToken: string }>(),
- INIT_USER: ofType<{ user: User, token: string }>(),
+ SET_EXTRA_TOKEN: ofType<{ extraApiToken: string, extraApiTokenExpiration?: Date }>(),
+ INIT_USER: ofType<{ user: User, token: string, tokenExpiration?: Date }>(),
USER_DETAILS_REQUEST: {},
USER_DETAILS_SUCCESS: ofType<User>(),
SET_SSH_KEYS: ofType<SshKeyResource[]>(),
setAuthorizationHeader(svc, token);
try {
const user = await svc.authService.getUserDetails();
- dispatch(authActions.INIT_USER({ user, token }));
+ const client = await svc.apiClientAuthorizationService.get('current');
+ const tokenExpiration = client.expiresAt ? new Date(client.expiresAt) : undefined;
+ dispatch(authActions.INIT_USER({ user, token, tokenExpiration }));
} catch (e) {
dispatch(authActions.LOGOUT({ deleteLinkData: false }));
}
// allow token creation and there's no way to know that from workbench2 side in advance.
const client = await services.apiClientAuthorizationService.create(undefined, false);
const newExtraToken = getTokenV2(client);
- dispatch(authActions.SET_EXTRA_TOKEN({ extraToken: newExtraToken }));
+ dispatch(authActions.SET_EXTRA_TOKEN({
+ extraApiToken: newExtraToken,
+ extraApiTokenExpiration: client.expiresAt ? new Date(client.expiresAt): undefined,
+ }));
return newExtraToken;
} catch {
console.warn("Cannot create new tokens with the current token, probably because of cluster's security settings.");