Files
games/features/auth/pages/register.templ
Ryan Hamamura 72d31fd143
Some checks failed
CI / Deploy / test (pull_request) Successful in 33s
CI / Deploy / lint (pull_request) Failing after 38s
CI / Deploy / deploy (pull_request) Has been skipped
fix: convert auth flows from SSE to standard HTTP to fix session cookies
Datastar's NewSSE() flushes HTTP headers before SCS's session middleware
can attach the Set-Cookie header, so the session cookie never reaches the
browser after login/register/logout.

Convert login, register, and logout to standard HTML forms with HTTP
redirects, which lets SCS write cookies normally. Also fix return_url
capture on the login page (was never being stored in the session).

Add handler tests covering login, register, and logout flows.
2026-03-11 10:10:28 -10:00

51 lines
1.3 KiB
Plaintext

package pages
import "github.com/ryanhamamura/games/features/common/layouts"
templ RegisterPage(errorMsg string) {
@layouts.Base("Register") {
<main class="max-w-sm mx-auto mt-8 text-center">
<h1 class="text-3xl font-bold">Register</h1>
<p class="mb-4">Create a new account</p>
if errorMsg != "" {
<div class="alert alert-error mb-4">{ errorMsg }</div>
}
<form method="POST" action="/auth/register">
<fieldset class="fieldset">
<label class="label" for="username">Username</label>
<input
class="input input-bordered w-full"
id="username"
name="username"
type="text"
placeholder="Choose a username"
autofocus
/>
<label class="label" for="password">Password</label>
<input
class="input input-bordered w-full"
id="password"
name="password"
type="password"
placeholder="Choose a password (min 8 chars)"
/>
<label class="label" for="confirm">Confirm Password</label>
<input
class="input input-bordered w-full"
id="confirm"
name="confirm"
type="password"
placeholder="Confirm your password"
/>
</fieldset>
<button type="submit" class="btn btn-primary w-full">
Register
</button>
</form>
<p>
Already have an account? <a class="link" href="/login">Login</a>
</p>
</main>
}
}