Skip to content

Commit f20bcad

Browse files
committed
fix(backend): 修复oldNotFound逻辑错误
1 parent 4794bb5 commit f20bcad

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

backend/pkg/service/group.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@ func (s *ServiceGroup) GrantRoleByUid(uid string, newRole security.Role) error {
115115

116116
// 如果是角色切换:先从旧组移除,再添加到新组
117117
oldGroup, err := s.FindByOuAndCn(security.OuGroupSupplementary, oldRole.String())
118-
if !errors.Is(err, ErrNotFound) {
118+
oldNotFound := errors.Is(err, ErrNotFound)
119+
if err != nil && !oldNotFound {
119120
return err
120121
}
121-
oldNotFound := errors.Is(err, ErrNotFound)
122+
122123
if !oldNotFound {
123124
if err := s.repositoryGroup.Modify(s.repositoryGroup.BuildDn(oldGroup), nil, attr, nil); err != nil {
124125
return err

backend/pkg/service/manager.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,6 @@ func (s *ServiceManager) unregister(user *entity.User) error {
150150
func (s *ServiceManager) Unregister(uid string) error {
151151
user, err := s.serviceUser.FindByUid(uid)
152152
if err != nil {
153-
if !errors.Is(err, ErrNotFound) {
154-
return err
155-
}
156153
return err
157154
}
158155

0 commit comments

Comments
 (0)