File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -627,11 +627,15 @@ pub async fn add_group_member(
627627 . collect :: < ServerResult < _ > > ( ) ?,
628628 _ => {
629629 let ( _, auth_doc) = load_group ( & state, group_id) . await ?;
630- auth_doc
630+ let role_ids = auth_doc
631631 . roles
632632 . iter ( )
633633 . filter_map ( |( role_id, role) | ( role. name == "user" ) . then_some ( * role_id) )
634- . collect ( )
634+ . collect :: < HashSet < _ > > ( ) ;
635+ if role_ids. len ( ) != 1 {
636+ return Err ( ServerError :: BadRequest ) ;
637+ }
638+ role_ids
635639 }
636640 } ;
637641 if role_ids. is_empty ( ) {
@@ -767,7 +771,7 @@ pub async fn create_group_role(
767771 let realm_id = state. get_realm_id ( ) ;
768772
769773 let name = request. name . trim ( ) . to_string ( ) ;
770- if name. is_empty ( ) || name == "admin" {
774+ if name. is_empty ( ) || matches ! ( name. as_str ( ) , "admin" | "user" ) {
771775 return Err ( ServerError :: BadRequest ) ;
772776 }
773777
You can’t perform that action at this time.
0 commit comments