X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/71b9264c1720e619f8cfcb297a7848ece420c61c..ecd0b3c069eed7d411e3cec7d707b43ab6675081:/src/store/auth/auth-action-ssh.ts diff --git a/src/store/auth/auth-action-ssh.ts b/src/store/auth/auth-action-ssh.ts index 1fbdfdfa..6e9ddaab 100644 --- a/src/store/auth/auth-action-ssh.ts +++ b/src/store/auth/auth-action-ssh.ts @@ -5,8 +5,9 @@ import { dialogActions } from "~/store/dialog/dialog-actions"; import { Dispatch } from "redux"; import { RootState } from "~/store/store"; +import { getUserUuid } from "~/common/getuser"; import { ServiceRepository } from "~/services/services"; -import {snackbarActions, SnackbarKind} from "~/store/snackbar/snackbar-actions"; +import { snackbarActions, SnackbarKind } from "~/store/snackbar/snackbar-actions"; import { FormErrors, reset, startSubmit, stopSubmit } from "redux-form"; import { KeyType } from "~/models/ssh-key"; import { @@ -14,9 +15,7 @@ import { getAuthorizedKeysServiceError } from "~/services/authorized-keys-service/authorized-keys-service"; import { setBreadcrumbs } from "~/store/breadcrumbs/breadcrumbs-actions"; -import { - authActions, -} from "~/store/auth/auth-action"; +import { authActions } from "~/store/auth/auth-action"; export const SSH_KEY_CREATE_FORM_NAME = 'sshKeyCreateFormName'; export const SSH_KEY_PUBLIC_KEY_DIALOG = 'sshKeyPublicKeyDialog'; @@ -62,7 +61,8 @@ export const removeSshKey = (uuid: string) => export const createSshKey = (data: SshKeyCreateFormDialogData) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - const userUuid = getState().auth.user!.uuid; + const userUuid = getUserUuid(getState()); + if (!userUuid) { return; } const { name, publicKey } = data; dispatch(startSubmit(SSH_KEY_CREATE_FORM_NAME)); try { @@ -93,11 +93,10 @@ export const createSshKey = (data: SshKeyCreateFormDialogData) => export const loadSshKeysPanel = () => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { try { - dispatch(setBreadcrumbs([{ label: 'SSH Keys'}])); + dispatch(setBreadcrumbs([{ label: 'SSH Keys' }])); const response = await services.authorizedKeysService.list(); dispatch(authActions.SET_SSH_KEYS(response.items)); } catch (e) { return; } }; -