keys: fix key validation

Pub and private key settings only showed errors if both values were
truthy, but it did not validate if one input was falsy, in which
case it only showed the last error.

Removed truthy check as it is not needed.
OFF0 2 years ago
parent 4dd8dae483
commit 6a4266526d
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -541,19 +541,17 @@ importBtn.addEventListener('click', () => {
settingsForm.addEventListener('input', () => validKeys(privateKeyInput.value, pubKeyInput.value));
function validKeys(privatekey, pubkey) {
if (pubkey && privatekey) {
try {
if (getPublicKey(privatekey) === pubkey) {
statusMessage.hidden = true;
statusMessage.textContent = 'public-key corresponds to private-key';
importBtn.removeAttribute('disabled');
return true;
} else {
statusMessage.textContent = 'private-key does not correspond to public-key!'
}
} catch (e) {
statusMessage.textContent = `not a valid private-key: ${e.message || e}`;
try {
if (getPublicKey(privatekey) === pubkey) {
statusMessage.hidden = true;
statusMessage.textContent = 'public-key corresponds to private-key';
importBtn.removeAttribute('disabled');
return true;
} else {
statusMessage.textContent = 'private-key does not correspond to public-key!'
}
} catch (e) {
statusMessage.textContent = `not a valid private-key: ${e.message || e}`;
}
statusMessage.hidden = false;
importBtn.setAttribute('disabled', true);

Loading…
Cancel
Save