1 {% extends "base.html" %}
5 function lmno_login_loadend(request, username) {
6 if (request.status === 404) {
7 add_message("danger", "User authentication failed. Please try again.");
11 /* Now that user is logged in, advance to the desired page (if any). */
12 const url = new URL(window.location);
13 const next_param = url.searchParams.get('next');
15 window.location.href = next_param;
19 /* Otherwise, just report the successful login. */
20 add_message("success", `User ${username} logged in. Have fun.`);
23 function lmno_login(form) {
24 const username = form.username.value;
25 const password = form.password.value;
27 console.log("In lmno_login with username: " + username);
28 var request = new XMLHttpRequest();
29 request.addEventListener("loadend", () => lmno_login_loadend(request, username));
31 request.open("POST", "/login");
32 request.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
33 request.send(`{"username": "${username}", "password": "${password}"}`);
39 <!-- The return false prevents the page from being reloaded -->
40 <form id="login-form" onsubmit="lmno_login(this); return false">
41 <div class="form-field large">
42 <label for="username">Username</label>
43 <input type="text" id="username" required>
46 <div class="form-field large">
47 <label for="Password">Password</label>
48 <input type="password" id="password" required>
51 <div class="form-field large">
52 <button type="submit">