Can use backup routes from API
This commit is contained in:
parent
e159d3c963
commit
c68ddffc5e
@ -23,7 +23,8 @@ CREATE TABLE tokens
|
|||||||
right_inbox BOOLEAN NOT NULL DEFAULT false,
|
right_inbox BOOLEAN NOT NULL DEFAULT false,
|
||||||
right_file BOOLEAN NOT NULL DEFAULT false,
|
right_file BOOLEAN NOT NULL DEFAULT false,
|
||||||
right_auth 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
|
CREATE TABLE files
|
||||||
|
@ -18,6 +18,7 @@ pub struct CreateTokenBody {
|
|||||||
right_file: bool,
|
right_file: bool,
|
||||||
right_auth: bool,
|
right_auth: bool,
|
||||||
right_stats: bool,
|
right_stats: bool,
|
||||||
|
right_backup: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Serialize)]
|
#[derive(serde::Serialize)]
|
||||||
@ -63,6 +64,7 @@ pub async fn create(auth: AuthExtractor, req: web::Json<CreateTokenBody>) -> Htt
|
|||||||
right_file: req.right_file,
|
right_file: req.right_file,
|
||||||
right_auth: req.right_auth,
|
right_auth: req.right_auth,
|
||||||
right_stats: req.right_stats,
|
right_stats: req.right_stats,
|
||||||
|
right_backup: req.right_backup,
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
@ -146,7 +146,8 @@ impl FromRequest for AuthExtractor {
|
|||||||
|| (uri.starts_with("/api/inbox") && token.right_inbox)
|
|| (uri.starts_with("/api/inbox") && token.right_inbox)
|
||||||
|| (uri.starts_with("/api/file") && token.right_file)
|
|| (uri.starts_with("/api/file") && token.right_file)
|
||||||
|| (uri.starts_with("/api/auth/") && token.right_auth)
|
|| (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 {
|
if !authorized {
|
||||||
return Err(actix_web::error::ErrorBadRequest(
|
return Err(actix_web::error::ErrorBadRequest(
|
||||||
|
@ -35,6 +35,7 @@ pub struct Token {
|
|||||||
pub right_file: bool,
|
pub right_file: bool,
|
||||||
pub right_auth: bool,
|
pub right_auth: bool,
|
||||||
pub right_stats: bool,
|
pub right_stats: bool,
|
||||||
|
pub right_backup: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Token {
|
impl Token {
|
||||||
@ -80,4 +81,5 @@ pub struct NewToken<'a> {
|
|||||||
pub right_file: bool,
|
pub right_file: bool,
|
||||||
pub right_auth: bool,
|
pub right_auth: bool,
|
||||||
pub right_stats: bool,
|
pub right_stats: bool,
|
||||||
|
pub right_backup: bool,
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,7 @@ diesel::table! {
|
|||||||
right_file -> Bool,
|
right_file -> Bool,
|
||||||
right_auth -> Bool,
|
right_auth -> Bool,
|
||||||
right_stats -> Bool,
|
right_stats -> Bool,
|
||||||
|
right_backup -> Bool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ pub struct NewTokenInfo {
|
|||||||
pub right_file: bool,
|
pub right_file: bool,
|
||||||
pub right_auth: bool,
|
pub right_auth: bool,
|
||||||
pub right_stats: bool,
|
pub right_stats: bool,
|
||||||
|
pub right_backup: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new token
|
/// 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_inbox: new_token.right_inbox,
|
||||||
right_file: new_token.right_file,
|
right_file: new_token.right_file,
|
||||||
right_stats: new_token.right_stats,
|
right_stats: new_token.right_stats,
|
||||||
|
right_backup: new_token.right_backup,
|
||||||
};
|
};
|
||||||
|
|
||||||
let res = diesel::insert_into(tokens::table)
|
let res = diesel::insert_into(tokens::table)
|
||||||
|
@ -32,6 +32,7 @@ export interface NewToken {
|
|||||||
right_file: boolean;
|
right_file: boolean;
|
||||||
right_auth: boolean;
|
right_auth: boolean;
|
||||||
right_stats: boolean;
|
right_stats: boolean;
|
||||||
|
right_backup: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TokensApi {
|
export class TokensApi {
|
||||||
|
@ -37,6 +37,7 @@ export function CreateTokenDialog(p: {
|
|||||||
right_inbox: false,
|
right_inbox: false,
|
||||||
right_movement: false,
|
right_movement: false,
|
||||||
right_stats: false,
|
right_stats: false,
|
||||||
|
right_backup: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearForm = () => {
|
const clearForm = () => {
|
||||||
@ -79,6 +80,7 @@ export function CreateTokenDialog(p: {
|
|||||||
right_auth: true,
|
right_auth: true,
|
||||||
right_inbox: true,
|
right_inbox: true,
|
||||||
right_stats: false,
|
right_stats: false,
|
||||||
|
right_backup: false,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -216,6 +218,18 @@ export function CreateTokenDialog(p: {
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<br />
|
||||||
|
<CheckboxInput
|
||||||
|
editable
|
||||||
|
label="Right: backup routes"
|
||||||
|
checked={newToken.right_backup}
|
||||||
|
onValueChange={(v) => {
|
||||||
|
setNewToken({
|
||||||
|
...newToken,
|
||||||
|
right_backup: v,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button onClick={cancel}>Cancel</Button>
|
<Button onClick={cancel}>Cancel</Button>
|
||||||
|
@ -197,6 +197,12 @@ function TokensRouteInner(p: {
|
|||||||
flex: 2,
|
flex: 2,
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
field: "right_backup",
|
||||||
|
headerName: "Backup",
|
||||||
|
flex: 2,
|
||||||
|
type: "boolean",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
field: "actions",
|
field: "actions",
|
||||||
type: "actions",
|
type: "actions",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user