From 6051aaa98563d11b6c59d7703aec27010e6223f2 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Fri, 27 Dec 2024 04:04:54 +0100 Subject: [PATCH] based update --- Cargo.lock | 14 +++++++------- migrations/00001_based_update.sql | 13 +++++++++++++ src/route/user.rs | 2 +- 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 migrations/00001_based_update.sql diff --git a/Cargo.lock b/Cargo.lock index d5df935..570d0e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -158,7 +158,7 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "based" version = "0.1.0" -source = "git+https://git.hydrar.de/jmarya/based#cd10c64a1f96703894de9e40a95fd81cc50d244a" +source = "git+https://git.hydrar.de/jmarya/based#4e3107ce08aaf6f149880a00707f86f1e94683eb" dependencies = [ "bcrypt 0.16.0", "chrono", @@ -1737,9 +1737,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -2071,9 +2071,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" [[package]] name = "ryu" @@ -2552,9 +2552,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.91" +version = "2.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53cbcb5a243bd33b7858b1d7f4aca2153490815872d86d955d6ea29f743c035" +checksum = "70ae51629bf965c5c098cc9e87908a3df5301051a9e087d6f9bef5c9771ed126" dependencies = [ "proc-macro2", "quote", diff --git a/migrations/00001_based_update.sql b/migrations/00001_based_update.sql new file mode 100644 index 0000000..bed4396 --- /dev/null +++ b/migrations/00001_based_update.sql @@ -0,0 +1,13 @@ +CREATE TYPE session_kind AS ENUM ('api', 'user'); + +ALTER TABLE user_session + ADD COLUMN IF NOT EXISTS "created" timestamptz NOT NULL DEFAULT NOW(), + ADD COLUMN IF NOT EXISTS "csrf" UUID NOT NULL DEFAULT gen_random_uuid(), + ADD COLUMN IF NOT EXISTS "name" VARCHAR(255), + ADD COLUMN IF NOT EXISTS kind session_kind NOT NULL DEFAULT 'user'; + +CREATE TABLE IF NOT EXISTS user_profile_pic ( + username VARCHAR(255) NOT NULL PRIMARY KEY, + "image" bytea NOT NULL, + FOREIGN KEY (username) REFERENCES users(username) +); diff --git a/src/route/user.rs b/src/route/user.rs index 4abac17..de529ad 100644 --- a/src/route/user.rs +++ b/src/route/user.rs @@ -1,4 +1,4 @@ -use based::auth::{User, UserRole}; +use based::auth::{Sessions, User, UserRole}; use based::check_admin; use based::request::api::{api_error, vec_to_api, FallibleApiResponse}; use rocket::get;