diff options
| author | Mathias Magnusson <mathias@magnusson.space> | 2025-08-18 21:43:11 +0200 |
|---|---|---|
| committer | Mathias Magnusson <mathias@magnusson.space> | 2025-08-18 21:43:11 +0200 |
| commit | 3262d631fd1be55a5c85ede08d92a35c5fb7d2c4 (patch) | |
| tree | fb2a09e159dc8677b7587cba8d4c69c4b1b70d8e /src/index.tsx | |
| parent | 815de9906a014c2eb1a4fe2bd8cf1b3077f03c9c (diff) | |
| download | uneven-3262d631fd1be55a5c85ede08d92a35c5fb7d2c4.tar.gz | |
Get current user session
Diffstat (limited to 'src/index.tsx')
| -rw-r--r-- | src/index.tsx | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/index.tsx b/src/index.tsx index e029577..5975284 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,7 +3,7 @@ import { Hono } from "hono"; import { createClient } from "@libsql/client"; import { drizzle } from "drizzle-orm/libsql"; import { groupTable } from "./db/schema.js"; -import authRouter, { LoginForm } from "./auth.js"; +import authRouter, { getSession, LoginForm } from "./auth.js"; export const RP_ID = "localhost"; // "uneven.0m.nu"; export const ORIGIN = `http://${RP_ID}`; @@ -38,13 +38,16 @@ app.get("/", c => c.html( )); let colors = ["red", "green", "blue"]; -app.get("/button", c => c.html( - <button - hx-get="/button" - hx-swap="outerHTML" - style={{ backgroundColor: colors[Math.floor(Math.random() * colors.length)] }} - >disco button!</button> -)); +app.get("/button", async c => { + let session = await getSession(c); + return c.html( + <button + hx-get="/button" + hx-swap="outerHTML" + style={{ backgroundColor: colors[Math.floor(Math.random() * colors.length)] }} + >disco button! {session.user.name}</button> + ); +}); app.route("/auth", authRouter); |
