@@ -54,7 +54,7 @@ type UserService interface {
5454 CreateUser (userInfo * bean.UserInfo , token string , managerAuth func (resource , token string , object string ) bool ) ([]* bean.UserInfo , error )
5555 SelfRegisterUserIfNotExists (userInfo * bean.UserInfo ) ([]* bean.UserInfo , error )
5656 UpdateUser (userInfo * bean.UserInfo , token string , checkRBACForUserUpdate func (token string , userInfo * bean.UserInfo , isUserAlreadySuperAdmin bool ,
57- eliminatedRoleFilters , eliminatedGroupRoles []* repository.RoleModel ) (isAuthorised bool , err error ), managerAuth func (resource , token string , object string ) bool ) (* bean.UserInfo , error )
57+ eliminatedRoleFilters , eliminatedGroupRoles []* repository.RoleModel , mapOfExistingUserRoleGroup map [ string ] bool ) (isAuthorised bool , err error ), managerAuth func (resource , token string , object string ) bool ) (* bean.UserInfo , error )
5858 GetById (id int32 ) (* bean.UserInfo , error )
5959 GetAll () ([]bean.UserInfo , error )
6060 GetAllWithFilters (request * bean.ListingRequest ) (* bean.UserListingResponse , error )
@@ -635,7 +635,7 @@ func (impl *UserServiceImpl) mergeUserRoleGroup(oldUserRoleGroups []bean.UserRol
635635}
636636
637637func (impl * UserServiceImpl ) UpdateUser (userInfo * bean.UserInfo , token string , checkRBACForUserUpdate func (token string , userInfo * bean.UserInfo ,
638- isUserAlreadySuperAdmin bool , eliminatedRoleFilters , eliminatedGroupRoles []* repository.RoleModel ) (isAuthorised bool , err error ), managerAuth func (resource , token string , object string ) bool ) (* bean.UserInfo , error ) {
638+ isUserAlreadySuperAdmin bool , eliminatedRoleFilters , eliminatedGroupRoles []* repository.RoleModel , mapOfExistingUserRoleGroup map [ string ] bool ) (isAuthorised bool , err error ), managerAuth func (resource , token string , object string ) bool ) (* bean.UserInfo , error ) {
639639 //checking if request for same user is being processed
640640 isLocked := impl .getUserReqLockStateById (userInfo .Id )
641641 if isLocked {
@@ -684,6 +684,7 @@ func (impl *UserServiceImpl) UpdateUser(userInfo *bean.UserInfo, token string, c
684684 //loading policy for safety
685685 casbin2 .LoadPolicy ()
686686 var eliminatedRoles , eliminatedGroupRoles []* repository.RoleModel
687+ mapOfExistingUserRoleGroup := make (map [string ]bool )
687688 if userInfo .SuperAdmin == false {
688689 //Starts Role and Mapping
689690 userRoleModels , err := impl .userAuthRepository .GetUserRoleMappingByUserId (model .Id )
@@ -732,6 +733,7 @@ func (impl *UserServiceImpl) UpdateUser(userInfo *bean.UserInfo, token string, c
732733 }
733734 for _ , oldItem := range userCasbinRoles {
734735 oldGroupMap [oldItem ] = oldItem
736+ mapOfExistingUserRoleGroup [oldItem ] = true
735737 }
736738 // START GROUP POLICY
737739 for _ , item := range userInfo .UserRoleGroup {
@@ -802,7 +804,7 @@ func (impl *UserServiceImpl) UpdateUser(userInfo *bean.UserInfo, token string, c
802804 }
803805
804806 if checkRBACForUserUpdate != nil {
805- isAuthorised , err := checkRBACForUserUpdate (token , userInfo , isUserSuperAdmin , eliminatedRoles , eliminatedGroupRoles )
807+ isAuthorised , err := checkRBACForUserUpdate (token , userInfo , isUserSuperAdmin , eliminatedRoles , eliminatedGroupRoles , mapOfExistingUserRoleGroup )
806808 if err != nil {
807809 impl .logger .Errorw ("error in checking RBAC for user update" , "err" , err , "userInfo" , userInfo )
808810 return nil , err
0 commit comments