Commit 77bb5e0c authored by 皮倩雯's avatar 皮倩雯

fix: '解密bug修复'

parent 5192971b
Pipeline #87437 passed with stages
......@@ -116,7 +116,7 @@ const InitDataBase = props => {
padding: CryptoJS.pad.Pkcs7,
});
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
return decryptedStr?.toString();
};
//加密
......@@ -167,10 +167,10 @@ const InitDataBase = props => {
const onFinish = values => {
setCardLoading(true);
const obj = values;
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
saveConnectionNew({
ip: obj.ip,
dbName: obj.dbName,
......@@ -213,14 +213,15 @@ const InitDataBase = props => {
});
});
};
// 测试连接
const onCheck = e => {
setCardLoading(true);
const obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
connectionTest({
ip: obj.ip,
dbName: obj.dbName,
......@@ -249,13 +250,18 @@ const InitDataBase = props => {
console.log(err);
});
};
const isAlphanumeric = str => {
return /^[A-Za-z0-9]+$/.test(str);
};
// 获取数据库列表
const selectFocus = e => {
let params = form.getFieldsValue();
let pwd =
Decrypt(params.password) === '' || Decrypt(params.password).indexOf('\u0004') !== -1
? Encrypt(params.password)
: params.password;
let pwd = params.password;
if (params.password.length < 32 || !isAlphanumeric(params.password)) {
pwd = Encrypt(params.password);
}
getDataBaseList({
userName: params.userName || '',
password: pwd || '',
......
......@@ -36,16 +36,21 @@ const AddModal = props => {
});
return encrypted.ciphertext.toString().toUpperCase();
};
const isAlphanumeric = str => {
return /^[A-Za-z0-9]+$/.test(str);
};
// 提交
const onSubmit = () => {
form.validateFields().then(validate => {
if (validate) {
setLoading(true);
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
if (type === 'add') {
AddConnString({
...obj,
......@@ -82,10 +87,10 @@ const AddModal = props => {
};
const handleEdit = () => {
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
EditConnString({
...obj,
oldName: formObj.name,
......
......@@ -36,16 +36,20 @@ const AddModal = props => {
});
return encrypted.ciphertext.toString().toUpperCase();
};
const isAlphanumeric = str => {
return /^[A-Za-z0-9]+$/.test(str);
};
// 提交
const onSubmit = () => {
form.validateFields().then(validate => {
if (validate) {
setLoading(true);
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
if (type === 'add') {
AddConnString({
type: 'mysql',
......@@ -82,10 +86,10 @@ const AddModal = props => {
};
const handleEdit = () => {
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
EditConnString({
type: 'mysql',
...obj,
......
......@@ -36,16 +36,20 @@ const AddModal = props => {
});
return encrypted.ciphertext.toString().toUpperCase();
};
const isAlphanumeric = str => {
return /^[A-Za-z0-9]+$/.test(str);
};
// 提交
const onSubmit = () => {
form.validateFields().then(validate => {
if (validate) {
setLoading(true);
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
if (type === 'add') {
AddConnString({
...obj,
......@@ -82,10 +86,10 @@ const AddModal = props => {
};
const handleEdit = () => {
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
EditConnString({
type: 'oracle',
...obj,
......
......@@ -36,16 +36,17 @@ const AddModal = props => {
});
return encrypted.ciphertext.toString().toUpperCase();
};
// 提交
const onSubmit = () => {
form.validateFields().then(validate => {
if (validate) {
setLoading(true);
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
if (type === 'add') {
AddConnString({
...obj,
......@@ -80,12 +81,16 @@ const AddModal = props => {
}
});
};
const isAlphanumeric = str => {
return /^[A-Za-z0-9]+$/.test(str);
};
const handleEdit = () => {
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
EditConnString({
...obj,
oldName: formObj.name,
......
......@@ -36,16 +36,21 @@ const AddModal = props => {
});
return encrypted.ciphertext.toString().toUpperCase();
};
const isAlphanumeric = str => {
return /^[A-Za-z0-9]+$/.test(str);
};
// 提交
const onSubmit = () => {
form.validateFields().then(validate => {
if (validate) {
setLoading(true);
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
if (type === 'add') {
AddConnString({
...obj,
......@@ -82,10 +87,10 @@ const AddModal = props => {
};
const handleEdit = () => {
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
EditConnString({
...obj,
oldName: formObj.name,
......
......@@ -94,12 +94,16 @@ const AppendModal = props => {
return encrypted.ciphertext.toString().toUpperCase();
};
const isAlphanumeric = str => {
return /^[A-Za-z0-9]+$/.test(str);
};
const getProduct = () => {
setLoading(true);
let pwd =
Decrypt(value.password) === '' || Decrypt(value.password).indexOf('\u0004') !== -1
? Encrypt(value.password)
: value.password;
let pwd = value.password;
if (value.password.length < 32 || !isAlphanumeric(value.password)) {
pwd = Encrypt(value.password);
}
GetLicenseDifference({ ...value, password: pwd }).then(res => {
setLoading(false);
if (res.code === 0) {
......
......@@ -439,12 +439,16 @@ const DatabaseInitialization = props => {
});
};
const isAlphanumeric = str => {
return /^[A-Za-z0-9]+$/.test(str);
};
const GetDbChangeFirst = kk => {
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
GetDbProduct({ ...obj, password: pwd }).then(res => {
setCardLoading(false);
if (res.code === 0) {
......@@ -495,10 +499,10 @@ const DatabaseInitialization = props => {
const GetDbChange = e => {
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
GetDbProduct({ ...obj, password: pwd }).then(res => {
setCardLoading(false);
if (res.code === 0) {
......@@ -614,10 +618,10 @@ const DatabaseInitialization = props => {
const GetDbChangeAppend = () => {
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
GetDbProduct({ ...obj, password: pwd }).then(res => {
setCardLoading(false);
if (res.code === 0) {
......@@ -702,10 +706,10 @@ const DatabaseInitialization = props => {
handleShowModal('initVisible', false);
setInitVisible(true);
doInitLog();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
NewInitAddDataBase({ ...obj, productSetting, password: pwd }).then(res => {
if (res.code === 0) {
GetDbChangeAppend(); // 刷星已初始化的产品勾选
......@@ -764,10 +768,10 @@ const DatabaseInitialization = props => {
setInitVisible(true);
doInitLog();
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
InitEditDataBase({
...obj,
password: pwd,
......@@ -833,10 +837,10 @@ const DatabaseInitialization = props => {
// setKeepValue([]);
setProduct([]);
setCardLoading(true);
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
GetProductList({ ...obj, password: pwd }).then(res => {
if (res.code === 0) {
console.log(res.data);
......@@ -870,10 +874,10 @@ const DatabaseInitialization = props => {
const onCheckLaster = aa => {
// 此时有授权码才能进入
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => {
setCardLoading(false);
if (res.code == 0) {
......@@ -918,10 +922,10 @@ const DatabaseInitialization = props => {
setAppendType('no');
let obj = form.getFieldsValue();
if (obj.ip && obj.userName && obj.password && obj.dbName && obj.providerType) {
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
GetProductList({ ...obj, password: pwd }).then(res => {
setCardLoading(false);
if (res.code === 0) {
......@@ -951,10 +955,10 @@ const DatabaseInitialization = props => {
const findCheck = aa => {
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => {
setCardLoading(false);
if (res.code === 0) {
......@@ -1004,10 +1008,10 @@ const DatabaseInitialization = props => {
const findCheck1 = aa => {
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
let pwd = obj.password;
if (obj.password.length < 32 || !isAlphanumeric(obj.password)) {
pwd = Encrypt(obj.password);
}
CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => {
setCardLoading(false);
if (res.code === 0) {
......
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