In my code, the first AJAX call to the server checks the recaptcha and sanitises the data.
Is there a way for a malicious user to skip that process ?
Since this is client side javascript, could he just fill in the email and the password in the Firebase user creation code by editing the code ?
Actually, can the user edit my client side code to skip my protection mechanisms ?
$("#registerForm").submit(function(e) {
e.preventDefault();
var username = $("#username").val();
var email = $("#email").val();
var password = $("#password").val();
var confirmPassword = $("#confirmPassword").val();
var referer = $("#referer").val();
$this = $(this);
$.ajax({
type: "POST",
url: "register",
data: $this.serialize()
}).done(function(data) {
if (data) {
firebase.auth().createUserWithEmailAndPassword(data.email, data.password).then(userData => {
$.ajax({
type: "POST",
url: "register2",
data: userData.serialize()
}).done(function(result) {
if (result == "WORKED!") {
localStorage.setItem('success_msg_local', "Please check your inbox. You have 1 hour to confirm your email address. Failing to do so will delete the account and let you register again.");
window.location.href="/users/register";
}
else if (result == "FAILED1!") {
firebase.auth().signOut().then(function() {
localStorage.setItem('error_msg_local', 'Failed to Register. Try again.');
window.location.href="/users/register";
});
}
else if (result == "FAILED2!") {
firebase.auth().signOut().then(function() {
localStorage.setItem('error_msg_local', 'Failed to Register. An error occured. Please try again later.');
window.location.href="/users/register";
});
}
});
},function(error) {
var errorCode = error.code;
var errorMessage = error.message;
("ERROR 3: "+ errorCode +" "+errorMessage);
localStorage.setItem('error_msg_local', 'Failed to Register. Please wait 1 hour before trying again.');
window.location.href="/users/register";
});
}
else {
localStorage.setItem('error_msg_local', 'Recaptcha failed'); window.location.href = "/users/register";
}
}).fail(function( jqXHR, textStatus ) {
alert( "Request failed: " + textStatus );
});
});