Skip to content

Commit

Permalink
minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberSphinxxx committed Nov 13, 2024
1 parent 8adccc1 commit 820ec33
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions password_manager/password_manager_save/password_manage_save.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,20 @@ async function encryptData(data) {
form.addEventListener('submit', async function(e) {
e.preventDefault();

const password = passwordInput.value; // Get the password input value
const strength = evaluatePasswordStrength(password); // Evaluate password strength

// Only save if the password is strong enough
if (strength === 'Weak') {
errorMessage.textContent = 'Password is too weak. Please choose a stronger password.';
errorMessage.style.display = 'block';
return;
}

const passwordData = {
label: document.getElementById('label').value,
username: document.getElementById('username').value,
password: document.getElementById('password').value,
password: password,
dateAdded: new Date().toISOString()
};

Expand Down Expand Up @@ -91,19 +101,17 @@ form.addEventListener('submit', async function(e) {
errorMessage.style.display = 'none';
setTimeout(() => {
clearForm();
}, 2000)
}, 2000);
} catch (error) {
errorMessage.textContent = 'Error saving password: ' + error.message;
errorMessage.style.display = 'block';
successMessage.style.display = 'none';
}
});

// Clear form function
function clearForm() {
// Clear form function clearForm() {
document.getElementById('label').value = '';
document.getElementById('username').value = '';
document.getElementById('password').value = '';
strengthIndicator.textContent = '';
errorMessage.style.display = 'none';
}

0 comments on commit 820ec33

Please sign in to comment.