Skip to content

Commit

Permalink
Add email provider error checking to login page.
Browse files Browse the repository at this point in the history
  • Loading branch information
amin-xiv committed Nov 14, 2024
1 parent 1349aff commit 268f227
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions website/pages/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ <h6 style="text-align: center; color: rgb(197 197 197); font-weight: 500; font-s
const passwordInput = document.getElementById('passwordInput');
const emailValue = emailInput.value.trim();
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;

// Trusted email domains
const trustedDomains = ["gmail.com", "outlook.com", "yahoo.com", "hotmail.com", "protonmail.com", "icloud.com", "tutanota.com"];
const emailDomain = emailValue.split('@')[1];

// Make sure to return the password field to the type['password']
document.querySelector('.password-field').type = 'password';
Expand All @@ -206,6 +210,10 @@ <h6 style="text-align: center; color: rgb(197 197 197); font-weight: 500; font-s
alert('Invalid email address');
return;
}
if(!trustedDomains.includes(emailDomain)) {
alert('Please use a valid email address from trusted providers (e.g., Gmail, Outlook, Yahoo) etc.');
return;
}
if (passwordInput.value.length === 0) {
alert('Please enter your password');
return;
Expand Down

0 comments on commit 268f227

Please sign in to comment.