Can use backup routes from API

This commit is contained in:
2025-05-02 15:31:29 +02:00
parent e159d3c963
commit c68ddffc5e
9 changed files with 32 additions and 2 deletions

View File

@ -18,6 +18,7 @@ pub struct CreateTokenBody {
right_file: bool,
right_auth: bool,
right_stats: bool,
right_backup: bool,
}
#[derive(serde::Serialize)]
@ -63,6 +64,7 @@ pub async fn create(auth: AuthExtractor, req: web::Json<CreateTokenBody>) -> Htt
right_file: req.right_file,
right_auth: req.right_auth,
right_stats: req.right_stats,
right_backup: req.right_backup,
})
.await?;

View File

@ -146,7 +146,8 @@ impl FromRequest for AuthExtractor {
|| (uri.starts_with("/api/inbox") && token.right_inbox)
|| (uri.starts_with("/api/file") && token.right_file)
|| (uri.starts_with("/api/auth/") && token.right_auth)
|| (uri.starts_with("/api/stats") && token.right_stats);
|| (uri.starts_with("/api/stats") && token.right_stats)
|| (uri.starts_with("/api/backup") && token.right_backup);
if !authorized {
return Err(actix_web::error::ErrorBadRequest(

View File

@ -35,6 +35,7 @@ pub struct Token {
pub right_file: bool,
pub right_auth: bool,
pub right_stats: bool,
pub right_backup: bool,
}
impl Token {
@ -80,4 +81,5 @@ pub struct NewToken<'a> {
pub right_file: bool,
pub right_auth: bool,
pub right_stats: bool,
pub right_backup: bool,
}

View File

@ -76,6 +76,7 @@ diesel::table! {
right_file -> Bool,
right_auth -> Bool,
right_stats -> Bool,
right_backup -> Bool,
}
}

View File

@ -20,6 +20,7 @@ pub struct NewTokenInfo {
pub right_file: bool,
pub right_auth: bool,
pub right_stats: bool,
pub right_backup: bool,
}
/// Create a new token
@ -41,6 +42,7 @@ pub async fn create(new_token: NewTokenInfo) -> anyhow::Result<Token> {
right_inbox: new_token.right_inbox,
right_file: new_token.right_file,
right_stats: new_token.right_stats,
right_backup: new_token.right_backup,
};
let res = diesel::insert_into(tokens::table)