Skip to content

Commit ab98118

Browse files
committed
feat: GetClaimsをmap[string]interface{}でアサーションする
1 parent eda4385 commit ab98118

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

jwt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func Verify(c *gin.Context) {
147147

148148
func GetClaims(c *gin.Context) Claims {
149149
if claims, ok := c.Get("claims"); ok {
150-
return claims.(Claims)
150+
return claims.(map[string]interface{})
151151
} else {
152152
return nil
153153
}

jwt_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ func TestVerifyValidToken(t *testing.T) {
5656

5757
c.Request, _ = http.NewRequest("GET", "/", nil)
5858

59-
token, err := GetToken(map[string]interface{}{})
59+
token, err := GetToken(Claims{})
6060

6161
c.Request.Header.Add("Authorization", "bearer "+string(token))
6262

6363
Verify(c)
6464

6565
assert.Equal(t, res.Code, http.StatusOK)
66-
assert.Equal(t, GetClaims(c), map[string]interface{}{})
66+
assert.Equal(t, GetClaims(c), Claims{})
6767
}

0 commit comments

Comments
 (0)