Implement basic auth

This commit is contained in:
Dominic Ferrando
2025-04-23 14:13:43 -04:00
parent 4018632080
commit a559aaebf4
11 changed files with 242 additions and 6 deletions
+44
View File
@@ -0,0 +1,44 @@
package admin
import "github.com/dominicf2001/comfychan/web/views/shared"
templ AdminLogin() {
@shared.Layout() {
<div class="admin-login-container">
<div style="display: none" id="adminLoginWarning" class="warning"></div>
<form
hx-post="/admin/login"
hx-swap="none"
id="adminLoginForm"
_="
on htmx:beforeRequest toggle @disabled on <button/> until htmx:afterRequest
on htmx:afterRequest
if event.detail.xhr.status is 401
show #adminLoginWarning
put event.detail.xhr.responseText into #adminLoginWarning
else
go to url /
end
"
>
<table>
<tbody>
<tr
class="new-post-form-field"
>
<th>Username</th>
<td><input required name="username"/></td>
</tr>
<tr
class="new-post-form-field"
>
<th>Password</th>
<td><input type="password" required name="password"/></td>
</tr>
</tbody>
</table>
<button type="submit">Submit</button>
</form>
</div>
}
}