From 1c524f181f31a63cbf63dacefcdf03de88b95fb8 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Fri, 20 Aug 2021 22:25:21 +0200 Subject: [PATCH] Removed role system --- .../2021-08-20-110251_users-and-auth/down.sql | 2 +- .../2021-08-20-110251_users-and-auth/up.sql | 27 +++---------------- src/rb/lib.rs | 4 --- src/rb/schema.rs | 21 +-------------- 4 files changed, 5 insertions(+), 49 deletions(-) diff --git a/migrations/2021-08-20-110251_users-and-auth/down.sql b/migrations/2021-08-20-110251_users-and-auth/down.sql index 08e4440..dba6dd6 100644 --- a/migrations/2021-08-20-110251_users-and-auth/down.sql +++ b/migrations/2021-08-20-110251_users-and-auth/down.sql @@ -1,2 +1,2 @@ -- This file should undo anything in `up.sql` -DROP TABLE IF EXISTS users, permissions, refresh_tokens, security_reports CASCADE; +DROP TABLE IF EXISTS users, refresh_tokens CASCADE; diff --git a/migrations/2021-08-20-110251_users-and-auth/up.sql b/migrations/2021-08-20-110251_users-and-auth/up.sql index 76de073..7ffd9f1 100644 --- a/migrations/2021-08-20-110251_users-and-auth/up.sql +++ b/migrations/2021-08-20-110251_users-and-auth/up.sql @@ -1,4 +1,3 @@ --- Users CREATE TABLE users ( id uuid DEFAULT gen_random_uuid() PRIMARY KEY, @@ -6,29 +5,9 @@ CREATE TABLE users ( -- Hashed + salted representation of the username password text NOT NULL, -- Wether the user is currently blocked - blocked boolean NOT NULL DEFAULT false -); - --- Permissions that a user can have -CREATE TABLE permissions ( - id uuid DEFAULT gen_random_uuid() PRIMARY KEY, - - user_id uuid REFERENCES users (id) NOT NULL, - name varchar(64) NOT NULL, - - UNIQUE (user_id, name) -); - --- Security reports (e.g. when a user is blocked) -CREATE TABLE security_reports ( - id uuid DEFAULT gen_random_uuid() PRIMARY KEY, - - -- When the report was made - report_time timestamp NOT NULL DEFAULT now(), - -- What type of report it is - report_type varchar(64) NOT NULL, - -- Contents of the report - content TEXT NOT NULL + blocked boolean NOT NULL DEFAULT false, + -- Wether the user is an admin + admin boolean NOT NULL DEFAULT false ); -- Stores refresh tokens diff --git a/src/rb/lib.rs b/src/rb/lib.rs index 5dcc829..e69de29 100644 --- a/src/rb/lib.rs +++ b/src/rb/lib.rs @@ -1,4 +0,0 @@ -pub const PERM_CODES: [&str; 2] = [ - "modify-blog-posts", - "modify-users" -]; diff --git a/src/rb/schema.rs b/src/rb/schema.rs index 6b8f42b..8dcb725 100644 --- a/src/rb/schema.rs +++ b/src/rb/schema.rs @@ -1,11 +1,3 @@ -table! { - permissions (id) { - id -> Uuid, - user_id -> Uuid, - name -> Varchar, - } -} - table! { refresh_tokens (token) { token -> Bytea, @@ -15,30 +7,19 @@ table! { } } -table! { - security_reports (id) { - id -> Uuid, - report_time -> Timestamp, - report_type -> Varchar, - content -> Text, - } -} - table! { users (id) { id -> Uuid, username -> Varchar, password -> Text, blocked -> Bool, + admin -> Bool, } } -joinable!(permissions -> users (user_id)); joinable!(refresh_tokens -> users (user_id)); allow_tables_to_appear_in_same_query!( - permissions, refresh_tokens, - security_reports, users, );