MSP-2175 handle no action required error
This commit is contained in:
1 parent
e65f5ac03c
commit
c77ab9d5f8
3 files changed
+11
-1
No files matched your search
@@ -17,6 +17,7 @@ var (
|
||||
ErrTokenNotFound = errors.New("token not found")
|
||||
ErrTooManyLoginRequests = errors.New("too many login requests")
|
||||
ErrUserIsBlocked = errors.New("user is blocked")
|
||||
ErrNoActionRequired = errors.New("no action required")
|
||||
)
|
||||
|
||||
type UnknownAuditEventError struct {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
"github.com/pkg/errors"
|
||||
"msp-admin-service/conf"
|
||||
"msp-admin-service/domain"
|
||||
"msp-admin-service/entity"
|
||||
)
|
||||
|
||||
@@ -90,6 +91,9 @@ func (r Repository) ModifyMemberAttr(ctx context.Context, userDn string, groupDn
|
||||
}
|
||||
|
||||
err := r.conn.Modify(modifyReq)
|
||||
if ldap.IsErrorAnyOf(err, ldap.LDAPResultUnwillingToPerform, ldap.LDAPResultEntryAlreadyExists) {
|
||||
return errors.WithMessage(domain.ErrNoActionRequired, err.Error())
|
||||
}
|
||||
if err != nil {
|
||||
return errors.WithMessagef(err, "modify entity by dn %s, operation: %s member from group", groupDn, operation)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/integration-system/isp-kit/log"
|
||||
"github.com/pkg/errors"
|
||||
"msp-admin-service/conf"
|
||||
"msp-admin-service/domain"
|
||||
"msp-admin-service/entity"
|
||||
)
|
||||
|
||||
@@ -102,6 +103,10 @@ func (s Service) SyncGroups(ctx context.Context, user entity.User) error {
|
||||
}
|
||||
|
||||
err := s.handleRole(ctx, role, userDn, operation, ldapRepo)
|
||||
if errors.Is(err, domain.ErrNoActionRequired) {
|
||||
s.logger.Info(ctx, "no action required, role is already synced")
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
s.logger.Error(ctx, errors.WithMessage(err, "handle role"))
|
||||
continue
|
||||
@@ -119,7 +124,7 @@ func (s Service) handleRole(
|
||||
ldapRepo Repo,
|
||||
) error {
|
||||
if role.ExternalGroup == "" {
|
||||
s.logger.Info(ctx, "role has not external group mapping, skip", log.Int("roleId", role.Id))
|
||||
s.logger.Info(ctx, "role has no external group mapping, skip", log.Int("roleId", role.Id))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user