Add basic login screen with form-based authentication
Adds /login route with HTML template that handles GET (show form) and POST (authenticate). On successful login, sets session cookie and redirects to /. Also adds framework support for redirects and cookies in route handlers. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,18 +1,29 @@
|
||||
import { DateTime } from "ts-luxon";
|
||||
import type { Call, Result, Route } from "../types";
|
||||
import { html, render } from "../util";
|
||||
import { loginRoute } from "./login";
|
||||
|
||||
const routes: Record<string, Route> = {
|
||||
hello: {
|
||||
path: "/hello",
|
||||
methods: ["GET"],
|
||||
handler: async (call: Call): Promise<Result> => {
|
||||
handler: async (_call: Call): Promise<Result> => {
|
||||
const now = DateTime.now();
|
||||
const c = await render("basic/hello", { now });
|
||||
|
||||
return html(c);
|
||||
},
|
||||
},
|
||||
home: {
|
||||
path:'/',
|
||||
methods:['GET'],
|
||||
handler:async(_call:Call): Promise<Result> => {
|
||||
const c = await render('basic/home')
|
||||
|
||||
return html(c)
|
||||
}
|
||||
},
|
||||
login: loginRoute,
|
||||
};
|
||||
|
||||
export { routes };
|
||||
|
||||
Reference in New Issue
Block a user