fix generate_challenge not working due to wrong method and only get the challenge if a username was supplied

This commit is contained in:
csd4ni3l
2025-08-12 15:55:30 +02:00
parent 37429706dd
commit ea4e4899d0
2 changed files with 18 additions and 18 deletions

View File

@@ -61,7 +61,7 @@ def user_loader(user_id):
user.id = user_id
return user
@app.route("/generate_challenge")
@app.route("/generate_challenge", methods=["POST"])
def generate_challenge_route():
username = request.json["username"]

View File

@@ -107,22 +107,6 @@ function read_file () {
filereader.readAsDataURL(file_input.files[0]);
}
function submit () {
username_input = document.getElementById("usernameinput")
grass_touching_form = document.getElementById("grass-touching-form")
if (grass_touching_form.hidden) {
if (username_input.value) {
grass_touching_form.hidden = false;
}
}
else {
read_file()
}
}
submit_button = document.getElementById("submit")
submit_button.addEventListener("click", submit)
function get_challenge() {
username_input = document.getElementById("usernameinput")
@@ -142,7 +126,23 @@ function get_challenge() {
})
}
window.onload = get_challenge;
function submit () {
username_input = document.getElementById("usernameinput")
grass_touching_form = document.getElementById("grass-touching-form")
if (grass_touching_form.hidden) {
if (username_input.value) {
grass_touching_form.hidden = false;
get_challenge();
}
}
else {
read_file();
}
}
submit_button = document.getElementById("submit")
submit_button.addEventListener("click", submit)
</script>