From af36c59851399194bcbb77a3093d46c2757cb7b4 Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Fri, 9 Aug 2024 23:30:10 +0900
Subject: feat: support authentication via fortee

---
 backend/query.sql | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

(limited to 'backend/query.sql')

diff --git a/backend/query.sql b/backend/query.sql
index f0e4034..13bbbe6 100644
--- a/backend/query.sql
+++ b/backend/query.sql
@@ -3,6 +3,11 @@ SELECT * FROM users
 WHERE users.user_id = $1
 LIMIT 1;
 
+-- name: CreateUser :one
+INSERT INTO users (username, display_name, is_admin)
+VALUES ($1, $1, false)
+RETURNING user_id;
+
 -- name: ListUsers :many
 SELECT * FROM users
 ORDER BY users.user_id;
@@ -13,6 +18,16 @@ JOIN user_auths ON users.user_id = user_auths.user_id
 WHERE users.username = $1
 LIMIT 1;
 
+-- name: CreateUserAuth :exec
+INSERT INTO user_auths (user_id, auth_type)
+VALUES ($1, $2);
+
+-- name: IsRegistrationTokenValid :one
+SELECT EXISTS (
+    SELECT 1 FROM registration_tokens
+    WHERE token = $1
+);
+
 -- name: ListGames :many
 SELECT * FROM games
 LEFT JOIN problems ON games.problem_id = problems.problem_id
-- 
cgit v1.3.1

