Login.tsx
| 1 | import { Layout } from "../layout.tsx"; |
| 2 | |
| 3 | interface LoginProps { |
| 4 | error?: string; |
| 5 | } |
| 6 | |
| 7 | export function Login({ error }: LoginProps) { |
| 8 | return ( |
| 9 | <Layout user={null} title="Sign in"> |
| 10 | <div class="auth-container"> |
| 11 | <h1 class="page-title">Sign in</h1> |
| 12 | {!!error && ( |
| 13 | <p class="form-error" safe> |
| 14 | {error} |
| 15 | </p> |
| 16 | )} |
| 17 | <form method="POST" action="/login" class="auth-form"> |
| 18 | <div class="form-group"> |
| 19 | <label for="username">Username</label> |
| 20 | <input |
| 21 | id="username" |
| 22 | name="username" |
| 23 | type="text" |
| 24 | required |
| 25 | autocomplete="username" |
| 26 | /> |
| 27 | </div> |
| 28 | <div id="passkey-section" style="display:none"> |
| 29 | <button |
| 30 | id="passkey-btn" |
| 31 | class="btn btn-secondary btn-block" |
| 32 | type="button" |
| 33 | > |
| 34 | Sign in with passkey |
| 35 | </button> |
| 36 | <p id="passkey-error" style="display:none"></p> |
| 37 | <div class="auth-divider"> |
| 38 | <span>or</span> |
| 39 | </div> |
| 40 | </div> |
| 41 | <div class="form-group"> |
| 42 | <label for="password">Password</label> |
| 43 | <input |
| 44 | id="password" |
| 45 | name="password" |
| 46 | type="password" |
| 47 | required |
| 48 | autocomplete="current-password" |
| 49 | /> |
| 50 | </div> |
| 51 | <button type="submit" class="btn btn-primary btn-block"> |
| 52 | Sign in with password |
| 53 | </button> |
| 54 | </form> |
| 55 | <p class="auth-footer"> |
| 56 | Don't have an account? <a href="/register">Register</a> |
| 57 | </p> |
| 58 | </div> |
| 59 | <script type="module" src="/assets/passkey-login.js"></script> |
| 60 | </Layout> |
| 61 | ); |
| 62 | } |
| 63 |