|
|
|
@ -276,7 +276,12 @@ func (s *UserSync) getUser(ctx context.Context, identity *authn.Identity) (*user |
|
|
|
|
if identity.AuthID != "" && identity.AuthModule != "" { |
|
|
|
|
query := &login.GetAuthInfoQuery{AuthId: identity.AuthID, AuthModule: identity.AuthModule} |
|
|
|
|
errGetAuthInfo := s.authInfoService.GetAuthInfo(ctx, query) |
|
|
|
|
if errGetAuthInfo == nil { |
|
|
|
|
|
|
|
|
|
if errGetAuthInfo != nil && !errors.Is(errGetAuthInfo, user.ErrUserNotFound) { |
|
|
|
|
return nil, nil, errGetAuthInfo |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if !errors.Is(errGetAuthInfo, user.ErrUserNotFound) { |
|
|
|
|
usr, errGetByID := s.userService.GetByID(ctx, &user.GetUserByIDQuery{ID: query.Result.UserId}) |
|
|
|
|
if errGetByID == nil { |
|
|
|
|
return usr, query.Result, nil |
|
|
|
@ -285,10 +290,13 @@ func (s *UserSync) getUser(ctx context.Context, identity *authn.Identity) (*user |
|
|
|
|
if !errors.Is(errGetByID, user.ErrUserNotFound) { |
|
|
|
|
return nil, nil, errGetByID |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if !errors.Is(errGetAuthInfo, user.ErrUserNotFound) { |
|
|
|
|
return nil, nil, errGetAuthInfo |
|
|
|
|
// if the user connected to user auth does not exist try to clean it up
|
|
|
|
|
if errors.Is(errGetByID, user.ErrUserNotFound) { |
|
|
|
|
if err := s.authInfoService.DeleteUserAuthInfo(ctx, query.Result.UserId); err != nil { |
|
|
|
|
s.log.FromContext(ctx).Error("Failed to clean up user auth", "error", err, "auth_module", identity.AuthModule, "auth_id", identity.AuthID) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|