Skip to content

Commit

Permalink
fix: validate
Browse files Browse the repository at this point in the history
  • Loading branch information
lulu-tro committed May 29, 2024
1 parent a03bf64 commit 7cef7c7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
17 changes: 11 additions & 6 deletions src/components/Modals/EncryptFileModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ export default function EncryptFileModal({ color }) {
return;
}

if (encryptType !== 'host' && !checkPassword()) {
if (encryptType !== 'host' && password==='') {
setValidateKeyMsg(t('validate_encryptkey_null'));
return ;
}

if (encryptType !== 'host' && !checkPassword(password)) {
return;
}

Expand Down Expand Up @@ -167,13 +172,13 @@ export default function EncryptFileModal({ color }) {
validateHostId(val);
};

const checkPassword = () => {
const checkPassword = (val) => {
const reg = /^[0-9A-Za-z]{6,20}$/g;
if (!password) {
setValidateKeyMsg(t('validate_encryptkey_null'));
return false;
if (!val || reg.test(val)) {
setValidateKeyMsg('');
return true;
}
if (!reg.test(password)) {
if (!reg.test(val)) {
setValidateKeyMsg(t('validate_encryptkey'));
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/Admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default function Admin() {
});
} else {
window.loading = false;
window.nodeStatus = false;
window.nodeStatus = true//false;
dispatch({
type: 'SET_NODE_STATUS',
nodeStatus: false,
Expand Down
8 changes: 4 additions & 4 deletions src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ const en_US = {
decrypt_file: 'Download file and decrypt',
encrypt_upload_file: 'Encrypt and upload',
encrypt_upload_file_desc:
"The client encrypts the file with the node's public key and uploads it to the BTFS network.",
"Encrypt the original file using either a specified node's public key or a self-set key, and then upload it to the BTFS network",
select_encrypt_file: 'Select file',
select_encrypt_file_btn: 'Browse',
cancel_encrypt_file_btn: 'Cancel',
Expand All @@ -377,7 +377,7 @@ const en_US = {
"Enter any node ID to encrypt the file using that node's public key. If turned off, the file will be encrypted using this node's public key by default",
decrypt_upload_file: 'Get and decrypt the file by CID',
decrypt_upload_file_desc:
"Enter the CID of the encrypted file, get the file from the BTFS network and decrypt it with the current node's private key",
"Retrieve the encrypted file from the BTFS network using the file CID and decrypt it with the current node's private key or a specified key",
dncrypt_file_cid: 'File CID',
decrypt_file_btn: 'Get File and Decrypt',
encrypt_import_success: 'Encrypt import successful',
Expand All @@ -401,14 +401,14 @@ const en_US = {
"set_encrypt_key_placeholder": "Set the file encryption and decryption key",
"validate_encryptkey_null": "Please enter the encryption key",
"validate_encryptkey": "Please enter an encryption key consisting of 6-20 characters, including letters and numbers",
"encrypt_file_with_host": "Encrypt file with the node's public key",
"encrypt_file_with_host": "Encrypt with node public key",
"encrypt_file_with_password": "Encrypt file with a key",
"encrypt_file_with_cur_host": "Encrypt file with this node's public key",
"encrypt_file_with_cur_host_desc": "Use this node's public key to encrypt the selected file. This node can decrypt the file.",
"encrypt_file_with_other_host": "Encrypt file with another node's public key",
"encrypt_file_with_other_host_desc": "Use the specified node's public key to encrypt the file. That node can decrypt the file.",

"decrypt_file_with_host": "Decrypt file with the node's private key",
"decrypt_file_with_host": "Decrypt with node private key",
"decrypt_file_with_password": "Decrypt file with a key",
"decrypt_file_password": "File decryption key",
"validate_decryptkey_null": "Please enter the file decryption key",
Expand Down
4 changes: 2 additions & 2 deletions src/locale/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,15 @@ const zh_CN = {
'encrypt_file':'加密文件并上传',
'decrypt_file':'下载文件并解密',
'encrypt_upload_file':'加密文件并上传',
'encrypt_upload_file_desc':'客户端通过节点公钥对文件进行加密并上传至BTFS网络',
'encrypt_upload_file_desc':'通过指定节点公钥或自设密钥对原始文件进行加密并上传至BTFS网络',
'select_encrypt_file':'选择文件',
'select_encrypt_file_btn':'浏览',
'cancel_encrypt_file_btn':'取消',
'encrypt_file_btn':'加密并上传',
'encrypt_file_hostid_title':'指定其他节点解密该文件',
'encrypt_file_hostid_desc':'输入任意节点ID以便使用该节点的公钥对文件进行加密。如关闭则默认使用本节点公钥对文件进行加密',
'decrypt_upload_file':'下载文件并解密',
'decrypt_upload_file_desc':'通过文件CID从BTFS网络获取加密文件并用当前节点私钥进行解密',
'decrypt_upload_file_desc':'通过文件CID从BTFS网络获取加密文件并用当前节点私钥或指定密钥进行解密',
'dncrypt_file_cid':'文件CID',
'decrypt_file_btn':'下载文件并解密',
'encrypt_import_success': '加密导入成功',
Expand Down

0 comments on commit 7cef7c7

Please sign in to comment.