I followed the tutorial on how to "login", "create user registration", and "change password using secret code". All screens work perfectly as per the tutorial, however, I CAN register with different usernames AND the same email address for both, which should NOT be allowed. You can see the security issue with that scenario. So, how do I make sure that the app checks the username AND the email address against the database to make sure there are no duplicated. The following code is right from the tutorial, and it does NOT execute the registerService if a username already exists. I also want to make sure the service DOES NOT execute when the same email is used by a different user. I'm sure it's only a few lines of code, but I'm not sure where to add them within the code below. Also, the following code is executed when btnRegister is clicked. I've provided an image of the Register screen as well:
if ($.trim(Appery("usernameInput").val()) !== "")
{
if (Appery("passwordInput").val() == Appery("confirmPasswordInput").val())
{
if ($.trim(Appery("emailInput").val()) !== "")
{
if (!document.getElementsByName("emailInput")[0].checkValidity || document.getElementsByName("emailInput")[0].checkValidity())
{
registerService.execute({});
}
else
{
alert("Please enter a valid email address.");
}
}
else
{
alert("Please enter your email address.");
}
}
else
{
alert("Passwords don't match.");
}
}
else
{
alert("Please enter your username.");
}