X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/b6ac7fe88d347582d39fffa002e300af222c578f..44821dc84765936ce99fa2d760ef683281f0a578:/src/store/auth/auth-reducer.ts diff --git a/src/store/auth/auth-reducer.ts b/src/store/auth/auth-reducer.ts index b8746ca5..c109acaf 100644 --- a/src/store/auth/auth-reducer.ts +++ b/src/store/auth/auth-reducer.ts @@ -13,6 +13,7 @@ export interface AuthState { user?: User; apiToken?: string; apiTokenExpiration?: Date; + apiTokenLocation?: string; extraApiToken?: string; extraApiTokenExpiration?: Date; sshKeys: SshKeyResource[]; @@ -29,6 +30,7 @@ const initialState: AuthState = { user: undefined, apiToken: undefined, apiTokenExpiration: undefined, + apiTokenLocation: undefined, extraApiToken: undefined, extraApiTokenExpiration: undefined, sshKeys: [], @@ -71,17 +73,18 @@ export const authReducer = (services: ServiceRepository) => (state = initialStat ({ ...state, extraApiToken, extraApiTokenExpiration }), RESET_EXTRA_TOKEN: () => ({ ...state, extraApiToken: undefined, extraApiTokenExpiration: undefined }), - INIT_USER: ({ user, token, tokenExpiration }) => + INIT_USER: ({ user, token, tokenExpiration, tokenLocation = state.apiTokenLocation }) => ({ ...state, user, apiToken: token, apiTokenExpiration: tokenExpiration, - homeCluster: user.uuid.substr(0, 5) + apiTokenLocation: tokenLocation, + homeCluster: user.uuid.substring(0, 5) }), LOGIN: () => state, LOGOUT: () => ({ ...state, apiToken: undefined }), USER_DETAILS_SUCCESS: (user: User) => - ({ ...state, user, homeCluster: user.uuid.substr(0, 5) }), + ({ ...state, user, homeCluster: user.uuid.substring(0, 5) }), SET_SSH_KEYS: (sshKeys: SshKeyResource[]) => ({ ...state, sshKeys }), ADD_SSH_KEY: (sshKey: SshKeyResource) => ({ ...state, sshKeys: state.sshKeys.concat(sshKey) }),