@@ -415,11 +415,8 @@ func (impl *UserServiceImpl) createUserIfNotExists(userInfo *bean.UserInfo, emai
415
415
if hasAccessToGroup {
416
416
policies = append (policies , casbin2.Policy {Type : "g" , Sub : casbin2 .Subject (userInfo .EmailId ), Obj : casbin2 .Object (userGroup .CasbinName )})
417
417
} else {
418
- trimmedGroup := strings .TrimPrefix (item .RoleGroup .Name , "group:" )
419
- restrictedGroups = append (restrictedGroups , bean.RestrictedGroup {
420
- Group : trimmedGroup ,
421
- HasSuperAdminPermission : hasSuperAdminPermission ,
422
- })
418
+ restrictedGroup := adapter .CreateRestrictedGroup (item .RoleGroup .Name , hasSuperAdminPermission )
419
+ restrictedGroups = append (restrictedGroups , restrictedGroup )
423
420
}
424
421
}
425
422
// END GROUP POLICY
@@ -787,11 +784,8 @@ func (impl *UserServiceImpl) UpdateUser(userInfo *bean.UserInfo, token string, m
787
784
groupsModified = true
788
785
addedPolicies = append (addedPolicies , casbin2.Policy {Type : "g" , Sub : casbin2 .Subject (userInfo .EmailId ), Obj : casbin2 .Object (userGroup .CasbinName )})
789
786
} else {
790
- trimmedGroup := strings .TrimPrefix (item .RoleGroup .Name , "group:" )
791
- restrictedGroups = append (restrictedGroups , bean.RestrictedGroup {
792
- Group : trimmedGroup ,
793
- HasSuperAdminPermission : hasSuperAdminPermission ,
794
- })
787
+ restrictedGroup := adapter .CreateRestrictedGroup (item .RoleGroup .Name , hasSuperAdminPermission )
788
+ restrictedGroups = append (restrictedGroups , restrictedGroup )
795
789
}
796
790
}
797
791
}
@@ -808,11 +802,8 @@ func (impl *UserServiceImpl) UpdateUser(userInfo *bean.UserInfo, token string, m
808
802
}
809
803
eliminatedPolicies = append (eliminatedPolicies , casbin2.Policy {Type : "g" , Sub : casbin2 .Subject (userInfo .EmailId ), Obj : casbin2 .Object (item )})
810
804
} else {
811
- trimmedGroup := strings .TrimPrefix (item , "group:" )
812
- restrictedGroups = append (restrictedGroups , bean.RestrictedGroup {
813
- Group : trimmedGroup ,
814
- HasSuperAdminPermission : hasSuperAdminPermission ,
815
- })
805
+ restrictedGroup := adapter .CreateRestrictedGroup (item , hasSuperAdminPermission )
806
+ restrictedGroups = append (restrictedGroups , restrictedGroup )
816
807
}
817
808
}
818
809
}
0 commit comments