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.
43 lines
1.1 KiB
Plaintext
43 lines
1.1 KiB
Plaintext
package pages
|
|
|
|
import "github.com/ryanhamamura/games/features/common/layouts"
|
|
|
|
templ LoginPage(errorMsg string) {
|
|
@layouts.Base("Login") {
|
|
<main class="max-w-sm mx-auto mt-8 text-center">
|
|
<h1 class="text-3xl font-bold">Login</h1>
|
|
<p class="mb-4">Sign in to your account</p>
|
|
if errorMsg != "" {
|
|
<div class="alert alert-error mb-4">{ errorMsg }</div>
|
|
}
|
|
<form method="POST" action="/auth/login">
|
|
<fieldset class="fieldset">
|
|
<label class="label" for="username">Username</label>
|
|
<input
|
|
class="input input-bordered w-full"
|
|
id="username"
|
|
name="username"
|
|
type="text"
|
|
placeholder="Enter your username"
|
|
autofocus
|
|
/>
|
|
<label class="label" for="password">Password</label>
|
|
<input
|
|
class="input input-bordered w-full"
|
|
id="password"
|
|
name="password"
|
|
type="password"
|
|
placeholder="Enter your password"
|
|
/>
|
|
</fieldset>
|
|
<button type="submit" class="btn btn-primary w-full">
|
|
Login
|
|
</button>
|
|
</form>
|
|
<p>
|
|
Don't have an account? <a class="link" href="/register">Register</a>
|
|
</p>
|
|
</main>
|
|
}
|
|
}
|