use crate::control::security::identity::{AuthenticatedIdentity, Role};
use crate::control::server::shared::ddl::result::{DdlError, DdlResult};
pub(super) fn status(command: &str) -> Vec<DdlResult> {
vec![DdlResult::Status {
command: command.to_string(),
rows_affected: None,
}]
}
pub(super) fn require_tenant_admin(
identity: &AuthenticatedIdentity,
action: &str,
) -> Result<(), DdlError> {
if identity.is_superuser || identity.has_role(&Role::TenantAdmin) {
Ok(())
} else {
Err(DdlError {
sqlstate: "42501".to_string(),
message: format!("permission denied: only superuser or tenant_admin can {action}"),
})
}
}
pub(super) fn parse_role(name: &str) -> Role {
match name.parse() {
Ok(role) => role,
Err(e) => match e {},
}
}