diff --git a/Rocket.toml.example b/Rocket.toml.example index a13f282..6ea1fb0 100644 --- a/Rocket.toml.example +++ b/Rocket.toml.example @@ -1,2 +1,8 @@ [global.limits] json = 5242880 + +[global.oauth.gitea] +provider = { auth_uri = "https://tulpa.dev/login/oauth/authorize", token_uri = "https://tulpa.dev/login/oauth/access_token" } +client_id = "..." +client_secret = "..." +redirect_uri = "http://localhost:8000/auth/gitea" \ No newline at end of file diff --git a/shell.nix b/shell.nix index f2e1cd1..d38355c 100644 --- a/shell.nix +++ b/shell.nix @@ -3,7 +3,7 @@ let rust = import ./nix/rust.nix { inherit sources; }; pkgs = import sources.nixpkgs { }; in pkgs.mkShell rec { - buildInputs = with pkgs; [ rust diesel-cli postgresql pgcli ]; + buildInputs = with pkgs; [ rust diesel-cli postgresql pgcli cargo-watch ]; DATABASE_URL = "postgresql://postgres:hunter2@localhost:5432/wasmcloud"; ROCKET_DATABASES = '' diff --git a/src/models.rs b/src/models.rs index 1959191..da3a86e 100644 --- a/src/models.rs +++ b/src/models.rs @@ -1,4 +1,4 @@ -use crate::schema::{gitea_tokens, users}; +use crate::schema::{gitea_tokens, users, tokens}; use chrono::NaiveDateTime; use serde::Serialize; use uuid::Uuid; @@ -33,8 +33,7 @@ pub struct NewGiteaToken { pub refresh_token: String, } -#[derive(Insertable, Queryable, Debug, Clone)] -#[table_name = "gitea_tokens"] +#[derive(Queryable, Debug, Clone)] pub struct GiteaToken { pub id: Uuid, pub user_id: Uuid, @@ -43,3 +42,18 @@ pub struct GiteaToken { pub created_at: NaiveDateTime, pub updated_at: NaiveDateTime, } + +#[derive(Insertable)] +#[table_name="tokens"] +pub struct NewToken { + pub user_id: Uuid, +} + +#[derive(Queryable, Debug, Clone, Serialize)] +pub struct Token { + pub id: Uuid, + pub user_id: Uuid, + pub created_at: NaiveDateTime, + pub updated_at: NaiveDateTime, + pub deleted_at: Option, +}