Skip to content

Commit

Permalink
Update jwt.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Cypaaa authored Dec 4, 2023
1 parent c224e14 commit cab8a38
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ import (
// Generate generates a JWT token. It takes a jwtSecretKey string and a struct (interface{})
// jwtSecretKey must be EdDSA private key
// and returns a token and an error.
func GenerateJWT(jwtSecretKey ed25519.PrivateKey, i interface{}) (string, error) {
func GenerateJWT(jwtSecretKey ed25519.PrivateKey, mc jwtv5.MapClaims) (string, error) {
token := jwtv5.New(jwtv5.SigningMethodEdDSA)
mc := token.Claims.(jwtv5.MapClaims)
v := reflect.ValueOf(i)
for i := 0; i < v.NumField(); i++ {
mc[v.Type().Field(i).Name] = v.Field(i).Interface()
}
token.Claims = mc
return token.SignedString(jwtSecretKey)
}

Expand Down

0 comments on commit cab8a38

Please sign in to comment.