Skip to content

Commit 5496b0d

Browse files
Fix: hotfix for get user with no roles (#1328)
* hotfix for no roles for system user - skip fetch data * info to warn for get user
1 parent d6461fb commit 5496b0d

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

pkg/user/UserService.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -676,14 +676,19 @@ func (impl UserServiceImpl) GetById(id int32) (*bean.UserInfo, error) {
676676
}
677677
}
678678

679-
filterGroupsModels, err := impl.roleGroupRepository.GetRoleGroupListByCasbinNames(filterGroups)
680-
if err != nil {
681-
impl.logger.Warnw("No Roles Found for user", "id", model.Id)
682-
}
683-
filterGroups = nil
684-
for _, item := range filterGroupsModels {
685-
filterGroups = append(filterGroups, item.Name)
679+
if len(filterGroups) > 0 {
680+
filterGroupsModels, err := impl.roleGroupRepository.GetRoleGroupListByCasbinNames(filterGroups)
681+
if err != nil {
682+
impl.logger.Warnw("No Roles Found for user", "id", model.Id)
683+
}
684+
filterGroups = nil
685+
for _, item := range filterGroupsModels {
686+
filterGroups = append(filterGroups, item.Name)
687+
}
688+
} else {
689+
impl.logger.Warnw("no roles found for user", "email", model.EmailId)
686690
}
691+
687692
if len(filterGroups) == 0 {
688693
filterGroups = make([]string, 0)
689694
}

0 commit comments

Comments
 (0)