fmt: Reduce cyclo complexity

This commit is contained in:
jamesread
2022-08-24 20:52:13 +01:00
parent c38b0351e4
commit e9fbcce220
2 changed files with 23 additions and 13 deletions

View File

@@ -23,8 +23,8 @@ var (
cfg *config.Config
)
func getClaimsFromJwtToken(cookieValue string) (jwt.MapClaims, error) {
token, err := jwt.Parse(cookieValue, func(token *jwt.Token) (interface{}, error) {
func parseToken(cookieValue string) (*jwt.Token, error) {
return jwt.Parse(cookieValue, func(token *jwt.Token) (interface{}, error) {
// Don't forget to validate the alg is what you expect:
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"])
@@ -33,6 +33,10 @@ func getClaimsFromJwtToken(cookieValue string) (jwt.MapClaims, error) {
// hmacSampleSecret is a []byte containing your secret, e.g. []byte("my_secret_key")
return []byte(cfg.AuthJwtSecret), nil
})
}
func getClaimsFromJwtToken(cookieValue string) (jwt.MapClaims, error) {
token, err := parseToken(cookieValue)
if err != nil {
log.Errorf("jwt parse failure: %v", err)