Web Dashboard: Mirror server-side email validation

This commit is contained in:
Crypto137 2025-10-23 22:12:18 +03:00
parent 08f4488040
commit ba0171d5c2

View file

@ -371,11 +371,18 @@ const createAccountTab = {
if (this.pendingAccountData != null)
return;
email.setCustomValidity("");
confirmPassword.setCustomValidity("");
if (email.reportValidity() == false || playerName.reportValidity() == false || password.reportValidity() == false)
return;
if (this.validateEmail(email.value) == false) {
email.setCustomValidity("Invalid email.");
email.reportValidity();
return;
}
if (password.value != confirmPassword.value) {
confirmPassword.setCustomValidity("Your passwords do not match.");
confirmPassword.reportValidity();
@ -400,6 +407,22 @@ const createAccountTab = {
this.pendingAccountData = null;
},
validateEmail(email) {
const atIndex = email.indexOf('@');
if (atIndex == -1)
return false;
const dotIndex = email.lastIndexOf('.');
if (dotIndex < atIndex)
return false;
const topDomainLength = email.length - (dotIndex + 1);
if (topDomainLength < 2)
return false;
return true;
},
getAccountOperationResultString(resultCode) {
const email = this.pendingAccountData.Email;
const playerName = this.pendingAccountData.PlayerName;