Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(user_role): Restrict updating user role to the same `EntityType` (#6224)
Mani Chandrab499287f2347
diff --git a/crates/router/src/core/user_role.rs b/crates/router/src/core/user_role.rsindex 5973a20dd3..9145706c10 100644--- a/crates/router/src/core/user_role.rs+++ b/crates/router/src/core/user_role.rs@@ -153,6 +153,14 @@ pub async fn update_user_role());}+ if role_info.get_entity_type() != role_to_be_updated.get_entity_type() {+ return Err(report!(UserErrors::InvalidRoleOperation)).attach_printable(format!(+ "Upgrade and downgrade of roles is not allowed, user_entity_type = {} req_entity_type = {}",+ role_to_be_updated.get_entity_type(),+ role_info.get_entity_type(),+ ));+ }+if updator_role.get_entity_type() < role_to_be_updated.get_entity_type() {return Err(report!(UserErrors::InvalidRoleOperation)).attach_printable(format!("Invalid operation, update requestor = {} cannot update target = {}",@@ -218,6 +226,14 @@ pub async fn update_user_role());}+ if role_info.get_entity_type() != role_to_be_updated.get_entity_type() {+ return Err(report!(UserErrors::InvalidRoleOperation)).attach_printable(format!(+ "Upgrade and downgrade of roles is not allowed, user_entity_type = {} req_entity_type = {}",+ role_to_be_updated.get_entity_type(),+ role_info.get_entity_type(),+ ));+ }+if updator_role.get_entity_type() < role_to_be_updated.get_entity_type() {return Err(report!(UserErrors::InvalidRoleOperation)).attach_printable(format!("Invalid operation, update requestor = {} cannot update target = {}",