web synchronized with the new changes
This commit is contained in:
@@ -27,7 +27,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_VALIDATION) {
|
||||
return Err(LoadError::Forbidden);
|
||||
}
|
||||
let mut definitions = state.definitions;
|
||||
@@ -43,7 +43,7 @@ pub(crate) async fn load_page(
|
||||
.flat_map(|profile| profile.tables.iter().map(|table| table.name.clone()))
|
||||
.collect();
|
||||
Ok(ValidationPageState {
|
||||
nav: crate::ui::Nav::new(headers, "admin").with_role(authorization.role),
|
||||
nav: crate::ui::Nav::new(headers, "admin").with_authorization(&authorization),
|
||||
profiles,
|
||||
tables,
|
||||
form,
|
||||
|
||||
@@ -127,7 +127,7 @@ fn render_set_loaded(
|
||||
Html(ui::render_set_page(nav, &form, error.as_deref())).into_response()
|
||||
}
|
||||
Err(LoadError::Unauthenticated) => Redirect::to("/login").into_response(),
|
||||
Err(LoadError::Forbidden) => (StatusCode::FORBIDDEN, Html(ui::render_error("Administrator access is required."))).into_response(),
|
||||
Err(LoadError::Forbidden) => (StatusCode::FORBIDDEN, Html(ui::render_error("Validation-management permission is required."))).into_response(),
|
||||
Err(LoadError::Backend(message)) => (StatusCode::BAD_GATEWAY, Html(ui::render_error(&message))).into_response(),
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,7 @@ fn render_loaded(result: Result<super::state::ValidationPageState, LoadError>) -
|
||||
match result {
|
||||
Ok(page) => Html(ui::render_page(&page)).into_response(),
|
||||
Err(LoadError::Unauthenticated) => Redirect::to("/login").into_response(),
|
||||
Err(LoadError::Forbidden) => (StatusCode::FORBIDDEN, Html(ui::render_error("Administrator access is required."))).into_response(),
|
||||
Err(LoadError::Forbidden) => (StatusCode::FORBIDDEN, Html(ui::render_error("Validation-management permission is required."))).into_response(),
|
||||
Err(LoadError::Backend(message)) => (StatusCode::BAD_GATEWAY, Html(ui::render_error(&message))).into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user