Removed the script from the login template

This commit is contained in:
2024-06-10 18:46:47 +01:00
parent 87788421cc
commit fd8f3720fb
2 changed files with 2 additions and 70 deletions
+1 -67
View File
@@ -15,70 +15,4 @@
</div>
</fieldset>
</form>
</div>
{{ if .script }}
<script>
// var loginForm = document.getElementById("login-form")
// function handleSuccessfulPOST(data) {
// console.log(data)
// const response = JSON.parse(data)
// // Need to add something that acts when the password is wrong
// // so that the user knows whats going on
// if (response["state"] === "success") {
// var endpoint = response["page"];
// window.location.replace(window.location.origin + endpoint)
// }
// }
// function handleForm(e) {
// e.preventDefault();
// // Get the login message from the textarea
// var loginUser = document.getElementById("login-user").value;
// var loginPass = document.getElementById("login-pass").value;
// // Create the JSON object to send
// var jsonData = {
// username: loginUser,
// password: loginPass,
// };
// // Configure the fetch request
// fetch("/send-login", {
// method: "POST",
// headers: {
// "Content-Type": "application/json"
// },
// body: JSON.stringify(jsonData)
// })
// .then(response => {
// // Check if the response is OK
// if (response.ok) {
// // Request was successful, handle response if needed
// return response.text();
// } else {
// // Request failed, handle error if needed
// throw new Error("Error: " + response.statusText);
// }
// })
// .then(data => {
// // We should only do a refresh if the login is correct
// handleSuccessfulPOST(data)
// })
// .catch(error => {
// console.error(error);
// });
// }
// loginForm.addEventListener("submit", (e) => {
// handleForm(e);
// });
// // Allows to login by actuating the login button on the page
// var submitBtn = document.getElementById("login-submit-button");
// submitBtn.addEventListener("click", handleForm);
</script>
{{ end }}
</div>
+1 -3
View File
@@ -5,9 +5,7 @@ import "net/http"
func LoginPage(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
loginTemplate := HtmlTemplate("./assets/htmx/login.html", map[string]interface{}{
"script": true,
})
loginTemplate := HtmlTemplate("./assets/htmx/login.html", nil)
loginPage := HtmlTemplate("./assets/htmx/terminal.html", map[string]interface{}{
"content": loginTemplate,