Skip to content

Commit

Permalink
editoast: fix after rebase
Browse files Browse the repository at this point in the history
Signed-off-by: Benoit Simard <[email protected]>
  • Loading branch information
sim51 committed Oct 23, 2024
1 parent 222242e commit 4ecb266
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions editoast/src/views/scenario/macro_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use crate::views::scenario::ScenarioIdParam;
use crate::views::study::StudyError;
use crate::views::study::StudyIdParam;
use crate::views::AuthorizationError;
use crate::views::AuthorizerExt;
use crate::views::AuthenticationExt;

crate::routes! {
"/macro_nodes" => {list, create,},
Expand Down Expand Up @@ -129,14 +129,14 @@ pub struct MacroNodeListResponse {
)]
async fn list(
State(db_pool): State<DbConnectionPoolV2>,
Extension(authorizer): AuthorizerExt,
Extension(auth): AuthenticationExt,
Path((project_id, study_id, scenario_id)): Path<(i64, i64, i64)>,
Query(pagination_params): Query<PaginationQueryParam>,
) -> Result<Json<MacroNodeListResponse>> {
let conn = &mut db_pool.get().await?;

// Checking role
let authorized = authorizer
let authorized = auth
.check_roles([BuiltinRole::OpsRead].into())
.await
.map_err(AuthorizationError::AuthError)?;
Expand Down Expand Up @@ -173,12 +173,12 @@ async fn list(
)]
async fn create(
State(db_pool): State<DbConnectionPoolV2>,
Extension(authorizer): AuthorizerExt,
Extension(auth): AuthenticationExt,
Path((project_id, study_id, scenario_id)): Path<(i64, i64, i64)>,
Json(data): Json<MacroNodeForm>,
) -> Result<Json<MacroNodeResponse>> {
// Checking role
let authorized = authorizer
let authorized = auth
.check_roles([BuiltinRole::OpsWrite].into())
.await
.map_err(AuthorizationError::AuthError)?;
Expand Down Expand Up @@ -231,11 +231,11 @@ async fn create(
)]
async fn get(
State(db_pool): State<DbConnectionPoolV2>,
Extension(authorizer): AuthorizerExt,
Extension(auth): AuthenticationExt,
Path((project_id, study_id, scenario_id, node_id)): Path<(i64, i64, i64, i64)>,
) -> Result<Json<MacroNodeResponse>> {
// Checking role
let authorized = authorizer
let authorized = auth
.check_roles([BuiltinRole::OpsRead].into())
.await
.map_err(AuthorizationError::AuthError)?;
Expand Down Expand Up @@ -269,11 +269,11 @@ async fn get(
)]
async fn update(
State(db_pool): State<DbConnectionPoolV2>,
Extension(authorizer): AuthorizerExt,
Extension(auth): AuthenticationExt,
Path((project_id, study_id, scenario_id, node_id)): Path<(i64, i64, i64, i64)>,
Json(data): Json<MacroNodeForm>,
) -> Result<Json<MacroNodeResponse>> {
let authorized = authorizer
let authorized = auth
.check_roles([BuiltinRole::OpsWrite].into())
.await
.map_err(AuthorizationError::AuthError)?;
Expand Down Expand Up @@ -335,10 +335,10 @@ async fn update(
)]
async fn delete(
State(db_pool): State<DbConnectionPoolV2>,
Extension(authorizer): AuthorizerExt,
Extension(auth): AuthenticationExt,
Path((project_id, study_id, scenario_id, node_id)): Path<(i64, i64, i64, i64)>,
) -> Result<impl IntoResponse> {
let authorized = authorizer
let authorized = auth
.check_roles([BuiltinRole::OpsWrite].into())
.await
.map_err(AuthorizationError::AuthError)?;
Expand Down

0 comments on commit 4ecb266

Please sign in to comment.