- } catch {
- session.loggedIn = false;
- } finally {
- session.status = SessionStatus.VALIDATED;
- dispatch(authActions.UPDATE_SESSION(session));
+ session.apiRevision = apiRevision;
+ };
+
+ let fail: Error | null = null;
+ const config = await getRemoteHostConfig(session.remoteHost, useApiClient);
+ if (config !== null) {
+ dispatch(authActions.REMOTE_CLUSTER_CONFIG({ config }));
+ try {
+ const { user, token } = await validateCluster(config, session.token);
+ setupSession(config.baseUrl, user, token, config.apiRevision);
+ } catch (e) {
+ fail = new Error(`Getting current user for ${session.remoteHost}: ${e.message}`);
+ try {
+ const { user, token } = await validateCluster(config, activeSession.token);
+ setupSession(config.baseUrl, user, token, config.apiRevision);
+ fail = null;
+ } catch (e2) {
+ if (e.message === invalidV2Token) {
+ fail = new Error(`Getting current user for ${session.remoteHost}: ${e2.message}`);
+ }
+ }
+ }
+ } else {
+ fail = new Error(`Could not get config for ${session.remoteHost}`);
+ }
+ session.status = SessionStatus.VALIDATED;
+ dispatch(authActions.UPDATE_SESSION(session));
+
+ if (fail) {
+ throw fail;