mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-07 12:23:41 +00:00
refactor: use slices.Contains to simplify (#5468)
Signed-off-by: zhedazijingang <unwrap_or_else@outlook.com>
This commit is contained in:
@@ -17,6 +17,7 @@ package token
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"slices"
|
||||
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
"github.com/rs/zerolog/log"
|
||||
@@ -55,13 +56,7 @@ func Parse(allowedTypes []Type, raw string, fn SecretFunc) (*Token, error) {
|
||||
return nil, jwt.ErrTokenUnverifiable
|
||||
}
|
||||
|
||||
hasAllowedType := false
|
||||
for _, k := range allowedTypes {
|
||||
if k == token.Type {
|
||||
hasAllowedType = true
|
||||
break
|
||||
}
|
||||
}
|
||||
hasAllowedType := slices.Contains(allowedTypes, token.Type)
|
||||
|
||||
if !hasAllowedType {
|
||||
return nil, jwt.ErrInvalidType
|
||||
|
Reference in New Issue
Block a user