diff --git a/static/build/index.js b/static/build/index.js index b4aa577..68990bb 100644 --- a/static/build/index.js +++ b/static/build/index.js @@ -14,6 +14,11 @@ document.addEventListener("DOMContentLoaded", function () { submitSignup(); }); + const usernameInput = document.getElementById("signup_username"); + usernameInput.addEventListener("blur", function () { + checkUsernameAvailability(); + }); + loginForm.addEventListener("submit", function (event) { event.preventDefault(); // Prevent the form from being submitted normally @@ -31,15 +36,9 @@ document.addEventListener("DOMContentLoaded", function () { } }); -const usernameInput = document.getElementById("signup-username"); -usernameInput.addEventListener("blur", function () { - checkUsernameAvailability(); -}); - - function checkUsernameAvailability() { - const usernameInput = document.getElementById("signup-username"); + const usernameInput = document.getElementById("signup_username"); const availabilityDiv = document.getElementById("usernameAvailability"); // Get the value of the username input @@ -78,18 +77,18 @@ function submitSignup() { submitBtn.innerHTML = ''; submitBtn.appendChild(spinner); - // Get the values of the signup form fields + // Get the values of the form fields + const signup_username = document.getElementById("signup_username").value; + const signup_password = document.getElementById("signup_password").value; const name = document.getElementById("name").value; const email = document.getElementById("email").value; - const username = document.getElementById("signup-username").value; - const password = document.getElementById("signup-password").value; // Create a new FormData object and append the values const formData = new FormData(); formData.append("name", name); formData.append("email", email); - formData.append("username", username); - formData.append("password", password); + formData.append("username", signup_username); + formData.append("password", signup_password); // Send the signup request as form data const xhr = new XMLHttpRequest(); diff --git a/templates/index.html b/templates/index.html index ac8ef6a..b6bc51a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -10,26 +10,6 @@ href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"> - @@ -176,7 +156,7 @@
@ -

-
diff --git a/user.go b/user.go index e483974..a0b968c 100644 --- a/user.go +++ b/user.go @@ -134,7 +134,7 @@ func Signup(w http.ResponseWriter, r *http.Request) { // Check if the request method is POST if r.Method == http.MethodPost { var creds Credentials - err := r.ParseForm() + err := r.ParseMultipartForm(0) if err != nil { log.Printf("Error parsing form: %v", err) http.Error(w, "Bad Request", http.StatusBadRequest)