Web Dashboard: Mirror server-side email validation
This commit is contained in:
parent
08f4488040
commit
ba0171d5c2
1 changed files with 23 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue