Commit 01aa4ee9 authored by 皮倩雯's avatar 皮倩雯

fix: '数据库密码密文展示'

parent a8bdb00d
Pipeline #79382 passed with stages
...@@ -92,6 +92,10 @@ const InitDataBase = props => { ...@@ -92,6 +92,10 @@ const InitDataBase = props => {
// 获取数据库配置信息 // 获取数据库配置信息
useEffect(() => { useEffect(() => {
// setTimeout(() => {
// document.getElementById('pwd').removeAttribute('value');
// }, 0);
setCardLoading(true); setCardLoading(true);
// 数据库连接记录初始化 // 数据库连接记录初始化
getConnRecordData(); getConnRecordData();
...@@ -105,14 +109,8 @@ const InitDataBase = props => { ...@@ -105,14 +109,8 @@ const InitDataBase = props => {
Object.keys(dbForm).forEach(k => { Object.keys(dbForm).forEach(k => {
obj[k] = res[k]; obj[k] = res[k];
}); });
console.log(obj, 'objohjfaosdjf'); form.setFieldsValue({ ...obj });
setDbForm(val => ({ ...val, ...obj }));
console.log(Decrypt(obj.password));
let aa = Decrypt(obj.password);
console.log(Encrypt(aa));
form.setFieldsValue({ ...obj, password: Decrypt(obj.password) });
setDbForm(val => ({ ...val, ...obj, password: Decrypt(obj.password) }));
setAllSqulDir(res.allSqlDir); setAllSqulDir(res.allSqlDir);
if (res.allSqlDir.some(item => item === inUse)) { if (res.allSqlDir.some(item => item === inUse)) {
setDefaultSqlDir(res.tableSQLDirName); setDefaultSqlDir(res.tableSQLDirName);
...@@ -256,11 +254,12 @@ const InitDataBase = props => { ...@@ -256,11 +254,12 @@ const InitDataBase = props => {
setCardLoading(true); setCardLoading(true);
const obj = values; const obj = values;
console.log(chooseDb.current, 'obj'); console.log(chooseDb.current, 'obj');
let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password;
saveConnectionNew({ saveConnectionNew({
ip: obj.ip, ip: obj.ip,
dbName: obj.dbName, dbName: obj.dbName,
userName: obj.userName, userName: obj.userName,
password: Encrypt(obj.password), password: pwd,
desc: chooseDb.current.desc, desc: chooseDb.current.desc,
}) })
.then(resnew => { .then(resnew => {
...@@ -271,7 +270,7 @@ const InitDataBase = props => { ...@@ -271,7 +270,7 @@ const InitDataBase = props => {
ip: obj.ip, ip: obj.ip,
dbName: obj.dbName, dbName: obj.dbName,
userName: obj.userName, userName: obj.userName,
password: Encrypt(obj.password), password: pwd,
}); });
// setUpData(upData + 1); // setUpData(upData + 1);
getConnRecordData(); getConnRecordData();
...@@ -295,18 +294,14 @@ const InitDataBase = props => { ...@@ -295,18 +294,14 @@ const InitDataBase = props => {
}; };
// 测试连接 // 测试连接
const onCheck = e => { const onCheck = e => {
console.log(dbForm);
setCardLoading(true); setCardLoading(true);
const obj = form.getFieldsValue(); const obj = form.getFieldsValue();
let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password;
connectionTest({ connectionTest({
// _version: 9999,
// _dc: new Date().getTime(),
ip: obj.ip, ip: obj.ip,
dbName: obj.dbName, dbName: obj.dbName,
userName: obj.userName, userName: obj.userName,
password: Encrypt(obj.password), password: pwd,
// Type:"SQLServer",
// name:obj.dbName,
}) })
.then(res => { .then(res => {
setCardLoading(false); setCardLoading(false);
...@@ -331,18 +326,15 @@ const InitDataBase = props => { ...@@ -331,18 +326,15 @@ const InitDataBase = props => {
}; };
// 获取数据库列表 // 获取数据库列表
const selectFocus = e => { const selectFocus = e => {
//setOption([]);
let params = form.getFieldsValue(); let params = form.getFieldsValue();
let pwd = Decrypt(params.password) === '' ? Encrypt(params.password) : params.password;
getDataBaseList({ getDataBaseList({
// _version: 9999,
// _dc: Date.now(),
userName: params.userName || '', userName: params.userName || '',
password: Encrypt(params.password) || '', password: pwd || '',
ip: params.ip || '', ip: params.ip || '',
}) })
.then(res => { .then(res => {
if (res.code == 0) { if (res.code == 0) {
console.log(res.data.root);
setOption(res.data.root); setOption(res.data.root);
} else { } else {
notification.error({ notification.error({
...@@ -364,7 +356,7 @@ const InitDataBase = props => { ...@@ -364,7 +356,7 @@ const InitDataBase = props => {
obj[k] = item[k]; obj[k] = item[k];
}); });
chooseDb.current = item; chooseDb.current = item;
form.setFieldsValue({ ...obj, password: Decrypt(obj.password) }); form.setFieldsValue({ ...obj });
}; };
// 产品方案选择框回调 // 产品方案选择框回调
const handleSelect = value => { const handleSelect = value => {
...@@ -421,7 +413,7 @@ const InitDataBase = props => { ...@@ -421,7 +413,7 @@ const InitDataBase = props => {
ip: obj.ip, ip: obj.ip,
dbName: obj.dbName, dbName: obj.dbName,
userName: obj.userName, userName: obj.userName,
password: Encrypt(obj.password), password: obj.password,
desc, desc,
}) })
.then(res => { .then(res => {
...@@ -467,7 +459,7 @@ const InitDataBase = props => { ...@@ -467,7 +459,7 @@ const InitDataBase = props => {
const GetDb = () => { const GetDb = () => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
GetDbProduct({ ...obj, password: Encrypt(obj.password) }).then(res => { GetDbProduct({ ...obj }).then(res => {
if (res.code === 0) { if (res.code === 0) {
console.log(res.data); console.log(res.data);
if (res.data.Product) { if (res.data.Product) {
...@@ -509,7 +501,7 @@ const InitDataBase = props => { ...@@ -509,7 +501,7 @@ const InitDataBase = props => {
setInitLoading(true); setInitLoading(true);
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let req1 = GetProductList(); let req1 = GetProductList();
let req2 = GetDbProduct({ ...obj, password: Encrypt(obj.password) }); let req2 = GetDbProduct({ ...obj });
Promise.all([req1, req2]) Promise.all([req1, req2])
.then(res => { .then(res => {
if (res[1].code !== 0 || res[0].code !== 0) { if (res[1].code !== 0 || res[0].code !== 0) {
...@@ -660,7 +652,7 @@ const InitDataBase = props => { ...@@ -660,7 +652,7 @@ const InitDataBase = props => {
...obj, ...obj,
productSetting, productSetting,
license: j, license: j,
password: Encrypt(obj.password), password: obj.password,
}).then(res => { }).then(res => {
setInitLoading(false); setInitLoading(false);
if (res.code === 0) { if (res.code === 0) {
...@@ -801,6 +793,7 @@ const InitDataBase = props => { ...@@ -801,6 +793,7 @@ const InitDataBase = props => {
form={form} form={form}
onFinish={onFinish} onFinish={onFinish}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
autoComplete="off"
> >
<Form.Item <Form.Item
label={`${formLables.ip}:`} label={`${formLables.ip}:`}
...@@ -832,10 +825,10 @@ const InitDataBase = props => { ...@@ -832,10 +825,10 @@ const InitDataBase = props => {
}, },
]} ]}
> >
<Input placeholder="请输入用户名称" /> <Input placeholder="请输入用户名称" autoComplete="off" />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label={`${formLables.password}:`} label="数据库用户密码"
name="password" name="password"
rules={[ rules={[
{ {
...@@ -849,10 +842,15 @@ const InitDataBase = props => { ...@@ -849,10 +842,15 @@ const InitDataBase = props => {
}, },
]} ]}
> >
<Input placeholder="请输入用户密码" type="password" /> <Input
placeholder="请输入用户密码"
type="password"
autoComplete="new-password"
id="pwd"
/>
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label={`${formLables.dbName}:`} label="数据库名称"
name="dbName" name="dbName"
rules={[ rules={[
{ {
......
...@@ -96,7 +96,8 @@ const AppendModal = props => { ...@@ -96,7 +96,8 @@ const AppendModal = props => {
const getProduct = () => { const getProduct = () => {
setLoading(true); setLoading(true);
GetLicenseDifference({ ...value, password: Encrypt(value.password) }).then(res => { let pwd = Decrypt(value.password) === '' ? Encrypt(value.password) : value.password;
GetLicenseDifference({ ...value, password: pwd }).then(res => {
setLoading(false); setLoading(false);
if (res.code === 0) { if (res.code === 0) {
setKeepData(res.data); setKeepData(res.data);
......
...@@ -367,7 +367,7 @@ const DatabaseInitialization = props => { ...@@ -367,7 +367,7 @@ const DatabaseInitialization = props => {
ip: resdata.data.ip, ip: resdata.data.ip,
dbName: resdata.data.dbName, dbName: resdata.data.dbName,
userName: resdata.data.userName, userName: resdata.data.userName,
password: Decrypt(resdata.data.password), password: resdata.data.password,
}); });
GetDbChangeFirst(kk); GetDbChangeFirst(kk);
// 有License的情况下首次进入展示数据 // 有License的情况下首次进入展示数据
...@@ -452,7 +452,8 @@ const DatabaseInitialization = props => { ...@@ -452,7 +452,8 @@ const DatabaseInitialization = props => {
const GetDbChangeFirst = kk => { const GetDbChangeFirst = kk => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
GetDbProduct({ ...obj, password: Encrypt(obj.password) }).then(res => { let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password;
GetDbProduct({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
if (res.data.IsAuthorize) { if (res.data.IsAuthorize) {
...@@ -502,7 +503,8 @@ const DatabaseInitialization = props => { ...@@ -502,7 +503,8 @@ const DatabaseInitialization = props => {
const GetDbChange = e => { const GetDbChange = e => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
GetDbProduct({ ...obj, password: Encrypt(obj.password) }).then(res => { let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password;
GetDbProduct({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
if (res.data.IsAuthorize) { if (res.data.IsAuthorize) {
...@@ -514,7 +516,7 @@ const DatabaseInitialization = props => { ...@@ -514,7 +516,7 @@ const DatabaseInitialization = props => {
} }
} else { } else {
let obj1 = form.getFieldsValue(); let obj1 = form.getFieldsValue();
CheckDatabaseIsExist({ ...obj1, password: Encrypt(obj.password) }).then(res1 => { CheckDatabaseIsExist({ ...obj1, password: pwd }).then(res1 => {
setCardLoading(false); setCardLoading(false);
if (res1.code === 0) { if (res1.code === 0) {
if ( if (
...@@ -617,7 +619,8 @@ const DatabaseInitialization = props => { ...@@ -617,7 +619,8 @@ const DatabaseInitialization = props => {
const GetDbChangeAppend = () => { const GetDbChangeAppend = () => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
GetDbProduct({ ...obj, password: Encrypt(obj.password) }).then(res => { let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password;
GetDbProduct({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
if (res.data.Product.length > 0) { if (res.data.Product.length > 0) {
...@@ -701,7 +704,8 @@ const DatabaseInitialization = props => { ...@@ -701,7 +704,8 @@ const DatabaseInitialization = props => {
handleShowModal('initVisible', false); handleShowModal('initVisible', false);
setInitVisible(true); setInitVisible(true);
doInitLog(); doInitLog();
NewInitAddDataBase({ ...obj, productSetting, password: Encrypt(obj.password) }).then(res => { let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password;
NewInitAddDataBase({ ...obj, productSetting, password: pwd }).then(res => {
if (res.code === 0) { if (res.code === 0) {
GetDbChangeAppend(); // 刷星已初始化的产品勾选 GetDbChangeAppend(); // 刷星已初始化的产品勾选
setMsg('未检测到可用License'); setMsg('未检测到可用License');
...@@ -756,9 +760,10 @@ const DatabaseInitialization = props => { ...@@ -756,9 +760,10 @@ const DatabaseInitialization = props => {
setInitVisible(true); setInitVisible(true);
doInitLog(); doInitLog();
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password;
InitEditDataBase({ InitEditDataBase({
...obj, ...obj,
password: Encrypt(obj.password), password: pwd,
isOldDbToNewDb: appendType === 'yes' ? true : false, isOldDbToNewDb: appendType === 'yes' ? true : false,
}).then(res => { }).then(res => {
if (res.code === 0) { if (res.code === 0) {
...@@ -852,7 +857,8 @@ const DatabaseInitialization = props => { ...@@ -852,7 +857,8 @@ const DatabaseInitialization = props => {
// setKeepValue([]); // setKeepValue([]);
setProduct([]); setProduct([]);
setCardLoading(true); setCardLoading(true);
GetProductList({ ...obj, password: Encrypt(obj.password) }).then(res => { let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password;
GetProductList({ ...obj, password: pwd }).then(res => {
if (res.code === 0) { if (res.code === 0) {
console.log(res.data); console.log(res.data);
GetDbChange(); GetDbChange();
...@@ -884,7 +890,8 @@ const DatabaseInitialization = props => { ...@@ -884,7 +890,8 @@ const DatabaseInitialization = props => {
// 非授权模式下环境检查 // 非授权模式下环境检查
const checkUnLicense = () => { const checkUnLicense = () => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
CheckDatabaseIsExist({ ...obj, password: Encrypt(obj.password) }).then(res => { let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password;
CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code !== 0) { if (res.code !== 0) {
setbeforeColor('red'); setbeforeColor('red');
...@@ -897,7 +904,8 @@ const DatabaseInitialization = props => { ...@@ -897,7 +904,8 @@ const DatabaseInitialization = props => {
const onCheckLaster = aa => { const onCheckLaster = aa => {
// 此时有授权码才能进入 // 此时有授权码才能进入
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
CheckDatabaseIsExist({ ...obj, password: Encrypt(obj.password) }).then(res => { let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password;
CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code == 0) { if (res.code == 0) {
setDataValue(form.getFieldsValue()); setDataValue(form.getFieldsValue());
...@@ -945,7 +953,8 @@ const DatabaseInitialization = props => { ...@@ -945,7 +953,8 @@ const DatabaseInitialization = props => {
setAppendType('no'); setAppendType('no');
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
if (obj.ip && obj.userName && obj.password && obj.dbName) { if (obj.ip && obj.userName && obj.password && obj.dbName) {
GetProductList({ ...obj, password: Encrypt(obj.password) }).then(res => { let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password;
GetProductList({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
GetDbChange(1); GetDbChange(1);
...@@ -974,7 +983,8 @@ const DatabaseInitialization = props => { ...@@ -974,7 +983,8 @@ const DatabaseInitialization = props => {
const findCheck = aa => { const findCheck = aa => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
CheckDatabaseIsExist({ ...obj, password: Encrypt(obj.password) }).then(res => { let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password;
CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
setDataValue(form.getFieldsValue()); setDataValue(form.getFieldsValue());
...@@ -1029,7 +1039,8 @@ const DatabaseInitialization = props => { ...@@ -1029,7 +1039,8 @@ const DatabaseInitialization = props => {
const findCheck1 = aa => { const findCheck1 = aa => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
CheckDatabaseIsExist({ ...obj, password: Encrypt(obj.password) }).then(res => { let pwd = Decrypt(obj.password) === '' ? Encrypt(obj.password) : obj.password;
CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
setDataValue(form.getFieldsValue()); setDataValue(form.getFieldsValue());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment