import { setCookie } from "$std/http/cookie.ts"; import { Handlers } from "$fresh/server.ts"; import { Head } from "$fresh/runtime.ts"; import Button from "../components/Button.tsx"; import Input from "../components/Input.tsx"; const LOGIN_MAX_AGE = 60 * 60 * 24 * 7; export const handler: Handlers = { GET(_, ctx) { return ctx.render(); }, async POST(req, _) { const form = await req.formData(); const username = form.get("username")!.toString(); const password = form.get("password")!.toString(); const response = new Response("", { status: 303, headers: { location: "/library" }, }); setCookie(response.headers, { name: "username", value: username, maxAge: LOGIN_MAX_AGE, httpOnly: true, }); setCookie(response.headers, { name: "password", value: password, maxAge: LOGIN_MAX_AGE, httpOnly: true, }); return response; }, }; export default function LoginPage() { return ( <> musikspider
); }