Skip to content

Commit

Permalink
better flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard87 committed Oct 14, 2024
1 parent daab67b commit 4944477
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions api/utils/token/chained_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
type ChainedValidator struct{ validators []ValidatorInterface }

var _ ValidatorInterface = &ChainedValidator{}
var errNoIssuersFound = errors.New("no issuers found")
var errNoValidatorsFound = errors.New("no validators found")

func NewChainedValidator(validators ...ValidatorInterface) *ChainedValidator {
return &ChainedValidator{validators}
Expand All @@ -26,5 +26,9 @@ func (v *ChainedValidator) ValidateToken(ctx context.Context, token string) (Tok
errs = append(errs, err)
}

return nil, fmt.Errorf("%w: %v", errNoIssuersFound, errors.Join(errs...))
if len(errs) > 0 {
return nil, fmt.Errorf("no issuers could validate token: %w", errors.Join(errs...))
}

return nil, errNoValidatorsFound
}

0 comments on commit 4944477

Please sign in to comment.