Skip to content

Commit

Permalink
fix: fix warning in ssh tunnel (#22912)
Browse files Browse the repository at this point in the history
  • Loading branch information
AAfghahi committed Jan 31, 2023
1 parent 88119a9 commit 16800cc
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import {
ExtraJson,
} from 'src/views/CRUD/data/database/types';
import Loading from 'src/components/Loading';
import { pick } from 'lodash';
import ExtraOptions from './ExtraOptions';
import SqlAlchemyForm from './SqlAlchemyForm';
import DatabaseConnectionForm from './DatabaseConnectionForm';
Expand Down Expand Up @@ -372,29 +373,41 @@ export function dbReducer(
[action.payload.name]: action.payload.value,
},
};
case ActionType.setSSHTunnelLoginMethod:
case ActionType.setSSHTunnelLoginMethod: {
let ssh_tunnel = {};
if (trimmedState?.ssh_tunnel) {
// remove any attributes that are considered sensitive
ssh_tunnel = pick(trimmedState.ssh_tunnel, [
'id',
'server_address',
'server_port',
'username',
]);
}
if (action.payload.login_method === AuthType.privateKey) {
const { password, ...rest } = trimmedState?.ssh_tunnel ?? {};
return {
...trimmedState,
ssh_tunnel: {
...rest,
private_key: trimmedState?.ssh_tunnel?.private_key,
private_key_password:
trimmedState?.ssh_tunnel?.private_key_password,
...ssh_tunnel,
},
};
}
if (action.payload.login_method === AuthType.password) {
const { private_key, private_key_password, ...rest } =
trimmedState?.ssh_tunnel ?? {};
return {
...trimmedState,
ssh_tunnel: {
...rest,
password: trimmedState?.ssh_tunnel?.password,
...ssh_tunnel,
},
};
}
return {
...trimmedState,
};
}
case ActionType.removeSSHTunnelConfig:
return {
...trimmedState,
Expand Down

0 comments on commit 16800cc

Please sign in to comment.