diff --git a/crates/sql-backend-handler/src/sql_schema_backend_handler.rs b/crates/sql-backend-handler/src/sql_schema_backend_handler.rs index da33a96..88082b6 100644 --- a/crates/sql-backend-handler/src/sql_schema_backend_handler.rs +++ b/crates/sql-backend-handler/src/sql_schema_backend_handler.rs @@ -34,22 +34,20 @@ impl SchemaBackendHandler for SqlBackendHandler { Box::pin(async move { // Check for conflicting group attribute with the same name but different type. // Done inside the transaction to prevent TOCTOU races. - let schema = - Self::get_schema_with_transaction(transaction).await?; + let schema = Self::get_schema_with_transaction(transaction).await?; if let Some(group_attr) = schema .group_attributes .attributes .iter() .find(|a| a.name == request.name) + && group_attr.attribute_type != request.attribute_type { - if group_attr.attribute_type != request.attribute_type { - return Err(DomainError::InternalError(format!( - "A group attribute '{}' already exists with type {:?}, \ + return Err(DomainError::InternalError(format!( + "A group attribute '{}' already exists with type {:?}, \ cannot create a user attribute with type {:?}. \ LDAP requires each attribute name to have a single type.", - request.name, group_attr.attribute_type, request.attribute_type - ))); - } + request.name, group_attr.attribute_type, request.attribute_type + ))); } let new_attribute = model::user_attribute_schema::ActiveModel { attribute_name: Set(request.name), @@ -73,22 +71,20 @@ impl SchemaBackendHandler for SqlBackendHandler { Box::pin(async move { // Check for conflicting user attribute with the same name but different type. // Done inside the transaction to prevent TOCTOU races. - let schema = - Self::get_schema_with_transaction(transaction).await?; + let schema = Self::get_schema_with_transaction(transaction).await?; if let Some(user_attr) = schema .user_attributes .attributes .iter() .find(|a| a.name == request.name) + && user_attr.attribute_type != request.attribute_type { - if user_attr.attribute_type != request.attribute_type { - return Err(DomainError::InternalError(format!( - "A user attribute '{}' already exists with type {:?}, \ + return Err(DomainError::InternalError(format!( + "A user attribute '{}' already exists with type {:?}, \ cannot create a group attribute with type {:?}. \ LDAP requires each attribute name to have a single type.", - request.name, user_attr.attribute_type, request.attribute_type - ))); - } + request.name, user_attr.attribute_type, request.attribute_type + ))); } let new_attribute = model::group_attribute_schema::ActiveModel { attribute_name: Set(request.name),