web synchronized with the new changes
This commit is contained in:
@@ -33,7 +33,7 @@ pub(crate) async fn load_page(
|
||||
_ => LoadError::Backend(error.message().to_string()),
|
||||
})?
|
||||
.into_inner();
|
||||
if authorization.role != "admin" {
|
||||
if !crate::authz::can_manage(&authorization, crate::authz::STRUCT_TABLE) {
|
||||
return Err(LoadError::Forbidden);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ pub(crate) async fn load_page(
|
||||
}
|
||||
|
||||
Ok(AddTablePageState {
|
||||
nav: crate::ui::Nav::new(headers, "admin").with_role(authorization.role),
|
||||
nav: crate::ui::Nav::new(headers, "admin").with_authorization(&authorization),
|
||||
profiles: tree
|
||||
.profiles
|
||||
.into_iter()
|
||||
|
||||
@@ -100,7 +100,10 @@ pub(crate) async fn create_table(
|
||||
let mut definitions = state.definitions;
|
||||
match definitions.post_table_definition(request).await {
|
||||
Ok(response) if response.get_ref().success => {
|
||||
let location = format!("/admin?profile={profile_name}");
|
||||
let location = format!(
|
||||
"/admin/table-definition?profile={profile_name}&table={}",
|
||||
page.draft.table_name
|
||||
);
|
||||
let Ok(location) = HeaderValue::try_from(location) else {
|
||||
return (StatusCode::INTERNAL_SERVER_ERROR, "Invalid redirect").into_response();
|
||||
};
|
||||
@@ -153,7 +156,7 @@ fn load_error_response(error: LoadError) -> Response {
|
||||
LoadError::Forbidden => (
|
||||
StatusCode::FORBIDDEN,
|
||||
Html(ui::render_submission_error(
|
||||
"Administrator access is required.",
|
||||
"Table-management permission is required.",
|
||||
)),
|
||||
)
|
||||
.into_response(),
|
||||
|
||||
Reference in New Issue
Block a user