From ec30ed1f0b2120a70331351a1f1afeac57285e71 Mon Sep 17 00:00:00 2001
From: Runxi Yu <me@runxiyu.org>
Date: Mon, 18 Aug 2025 04:18:50 +0800
Subject: Make logging in work

---
 forged/sql/queries/login.sql | 8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100644 forged/sql/queries/login.sql

(limited to 'forged/sql/queries/login.sql')

diff --git a/forged/sql/queries/login.sql b/forged/sql/queries/login.sql
new file mode 100644
index 0000000..ffc4026
--- /dev/null
+++ b/forged/sql/queries/login.sql
@@ -0,0 +1,8 @@
+-- name: GetUserCreds :one
+SELECT id, COALESCE(password_hash, '') FROM users WHERE username = $1;
+
+-- name: InsertSession :exec
+INSERT INTO sessions (user_id, token_hash, expires_at) VALUES ($1, $2, $3);
+
+-- name: GetUserFromSession :one
+SELECT user_id, COALESCE(username, '') FROM users u JOIN sessions s ON u.id = s.user_id WHERE s.token_hash = $1;
-- 
cgit v1.2.3

