Can use backup routes from API
This commit is contained in:
		@@ -23,7 +23,8 @@ CREATE TABLE tokens
 | 
			
		||||
    right_inbox    BOOLEAN      NOT NULL DEFAULT false,
 | 
			
		||||
    right_file     BOOLEAN      NOT NULL DEFAULT false,
 | 
			
		||||
    right_auth     BOOLEAN      NOT NULL DEFAULT false,
 | 
			
		||||
    right_stats    BOOLEAN      NOT NULL DEFAULT false
 | 
			
		||||
    right_stats    BOOLEAN      NOT NULL DEFAULT false,
 | 
			
		||||
    right_backup   BOOLEAN      NOT NULL DEFAULT false
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
CREATE TABLE files
 | 
			
		||||
 
 | 
			
		||||
@@ -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?;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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(
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -76,6 +76,7 @@ diesel::table! {
 | 
			
		||||
        right_file -> Bool,
 | 
			
		||||
        right_auth -> Bool,
 | 
			
		||||
        right_stats -> Bool,
 | 
			
		||||
        right_backup -> Bool,
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user