Skip to content

Commit

Permalink
fix: change string to interface in Payload func. (appleboy#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
appleboy authored May 24, 2018
1 parent a2cab93 commit 3011071
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion auth_jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type GinJWTMiddleware struct {
// Note that the payload is not encrypted.
// The attributes mentioned on jwt.io can't be used as keys for the map.
// Optional, by default no additional data will be set.
PayloadFunc func(userID string) map[string]interface{}
PayloadFunc func(userID interface{}) map[string]interface{}

// User can define own Unauthorized func.
Unauthorized func(*gin.Context, int, string)
Expand Down
4 changes: 2 additions & 2 deletions auth_jwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func TestLoginHandler(t *testing.T) {
authMiddleware := &GinJWTMiddleware{
Realm: "test zone",
Key: key,
PayloadFunc: func(userId string) map[string]interface{} {
PayloadFunc: func(userId interface{}) map[string]interface{} {
// Set custom claim, to be checked in Authorizator method
return map[string]interface{}{"testkey": "testval", "exp": 0}
},
Expand Down Expand Up @@ -632,7 +632,7 @@ func TestClaimsDuringAuthorization(t *testing.T) {
Key: key,
Timeout: time.Hour,
MaxRefresh: time.Hour * 24,
PayloadFunc: func(userId string) map[string]interface{} {
PayloadFunc: func(userId interface{}) map[string]interface{} {
var testkey string
switch userId {
case "admin":
Expand Down

0 comments on commit 3011071

Please sign in to comment.