func (ja *JWTAuth) Encode(claims map[string]interface{}) (t jwt.Token, tokenString string, err error) {
t = jwt.New()
for k, v := range claims {
t.Set(k, v)
}
payload, err := ja.sign(t)
if err != nil {
return nil, "", err
}
tokenString = string(payload)
return
}
If t.Set(k,v) returns error, we should handle it and error out earlier, instead of now just ignore it ?
Look at the API t.Set(k, v), depending on the key's name, it may fail if we provide a wrong type for that key, e.g. the sub has to be string.
If t.Set(k,v) returns error, we should handle it and error out earlier, instead of now just ignore it ? Look at the API t.Set(k, v), depending on the key's name, it may fail if we provide a wrong type for that key, e.g. the
sub
has to be string.