···5 <header>
6 <details>
7 <summary>Authentication</summary>
8- <div hx-get="/htmx/user_slug" hx-trigger="login from:body, load" hx-swap="innerHTML"></div>
0000000000000000009 <br />
10- <form hx-post="/user/login" hx-swap="none">
11 <label>Login with code: <br /><input name="pass" /></label>
12 <br /><button>Ok</button>
13 </form>
···43 <p>Acknowledgements:</p>
44 <ul>
45 <li>Axum for a lovely Rust web server.</li>
46- <li>HTMX for dead easy single-page-app prototyping.</li>
47 <li>
48 This lovely paper background.
49 <a href="https://projects.verou.me/css3patterns/#lined-paper">Thanks!</a>
···5 <header>
6 <details>
7 <summary>Authentication</summary>
8+ <script type="module">
9+ const span = document.querySelector("#authentication_span");
10+11+ const req = await fetch("/user/info", { method: "POST" });
12+13+ if (req.ok) {
14+ const user = await req.json();
15+16+ const body = `You are logged in. Your user ID is ${user.id}.
17+ <br> You are in timezone ${user.timezone}.
18+ <br><br> Your login code is <samp><input value=\"${user.pass}\" readonly></samp>.
19+ <br> Use this to log in on other devices. If you want to ensure your tasks are saved, write this code down.`;
20+ span.innerHTML = body;
21+ } else {
22+ const body = `You are not logged in`;
23+ span.innerHTML = body;
24+ }
25+ </script>
26+ <span id="authentication_span"></span>
27 <br />
28+ <form method="POST" action="/user/login" id="user-login">
29 <label>Login with code: <br /><input name="pass" /></label>
30 <br /><button>Ok</button>
31 </form>
···61 <p>Acknowledgements:</p>
62 <ul>
63 <li>Axum for a lovely Rust web server.</li>
064 <li>
65 This lovely paper background.
66 <a href="https://projects.verou.me/css3patterns/#lined-paper">Thanks!</a>