forked from Chewing_Bever/rusty-bever
Started some auth stuff
This commit is contained in:
parent
eefaf7acaa
commit
5e86133651
8 changed files with 153 additions and 9 deletions
|
|
@ -1,3 +1,4 @@
|
|||
pub fn yeet() -> String {
|
||||
String::from("yeet")
|
||||
}
|
||||
pub const PERM_CODES: [&str; 2] = [
|
||||
"modify-blog-posts",
|
||||
"modify-users"
|
||||
];
|
||||
|
|
|
|||
44
src/rb/schema.rs
Normal file
44
src/rb/schema.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
table! {
|
||||
permissions (id) {
|
||||
id -> Uuid,
|
||||
user_id -> Uuid,
|
||||
name -> Varchar,
|
||||
}
|
||||
}
|
||||
|
||||
table! {
|
||||
refresh_tokens (token) {
|
||||
token -> Bytea,
|
||||
user_id -> Uuid,
|
||||
expires_at -> Timestamp,
|
||||
last_used_at -> Nullable<Timestamp>,
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
joinable!(permissions -> users (user_id));
|
||||
joinable!(refresh_tokens -> users (user_id));
|
||||
|
||||
allow_tables_to_appear_in_same_query!(
|
||||
permissions,
|
||||
refresh_tokens,
|
||||
security_reports,
|
||||
users,
|
||||
);
|
||||
17
src/rbs/auth.rs
Normal file
17
src/rbs/auth.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
use crate::RbDbConn;
|
||||
use serde::Deserialize;
|
||||
use rocket::serde::json::Json;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Credentials {
|
||||
username: String,
|
||||
password: String
|
||||
}
|
||||
|
||||
#[post("/login", data="<credentials>")]
|
||||
async fn login(conn: RbDbConn, credentials: Json<Credentials>) {
|
||||
|
||||
}
|
||||
|
||||
// /refresh
|
||||
// /logout
|
||||
|
|
@ -8,6 +8,8 @@ extern crate openssl;
|
|||
use rocket::{fairing::AdHoc, Build, Rocket};
|
||||
use rocket_sync_db_pools::{database, diesel};
|
||||
|
||||
mod auth;
|
||||
|
||||
embed_migrations!();
|
||||
|
||||
#[database("postgres_rb")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue