正在显示
2 个修改的文件
包含
12 行增加
和
10 行删除
| @@ -8,14 +8,14 @@ import ( | @@ -8,14 +8,14 @@ import ( | ||
| 8 | ) | 8 | ) |
| 9 | 9 | ||
| 10 | type UserAuth struct { | 10 | type UserAuth struct { |
| 11 | - jwt.StandardClaims `json:"-"` | ||
| 12 | - UserId int64 `json:"userId"` | ||
| 13 | - CompanyId int64 `json:"companyId"` | ||
| 14 | - CompanyName string `json:"companyName"` | ||
| 15 | - Phone string `json:"phone"` | ||
| 16 | - PlatformId int `json:"platformId"` | ||
| 17 | - Name string `json:"name"` | ||
| 18 | - AdminType int `json:"adminType"` | 11 | + jwt.StandardClaims |
| 12 | + UserId int64 `json:"userId"` | ||
| 13 | + CompanyId int64 `json:"companyId"` | ||
| 14 | + CompanyName string `json:"companyName"` | ||
| 15 | + Phone string `json:"phone"` | ||
| 16 | + PlatformId int `json:"platformId"` | ||
| 17 | + Name string `json:"name"` | ||
| 18 | + AdminType int `json:"adminType"` | ||
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | var issuer = "performance" | 21 | var issuer = "performance" |
| @@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
| 7 | ) | 7 | ) |
| 8 | 8 | ||
| 9 | func TestGenerateToken(t *testing.T) { | 9 | func TestGenerateToken(t *testing.T) { |
| 10 | + JWTExpiresSecond = 2 | ||
| 10 | ut := UserAuth{ | 11 | ut := UserAuth{ |
| 11 | CompanyId: 8, | 12 | CompanyId: 8, |
| 12 | UserId: 3422185340122624, | 13 | UserId: 3422185340122624, |
| @@ -20,8 +21,9 @@ func TestGenerateToken(t *testing.T) { | @@ -20,8 +21,9 @@ func TestGenerateToken(t *testing.T) { | ||
| 20 | 21 | ||
| 21 | func TestParsetToken1(t *testing.T) { | 22 | func TestParsetToken1(t *testing.T) { |
| 22 | ut := UserAuth{} | 23 | ut := UserAuth{} |
| 23 | - str := `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjM0MjE4NDc3MjcyOTYwMDAsImNvbXBhbnlJZCI6MTAsImNvbXBhbnlOYW1lIjoi5aSp6IGU5L-h5oGv56eR5oqA5pyJ6ZmQ5YWs5Y-4IiwicGhvbmUiOiIxNTY1OTM3NTk0MCIsInBsYXRmb3JtSWQiOjI5LCJuYW1lIjoi5bq35Lyf5Y2OIiwiYWRtaW5UeXBlIjoxfQ.v4qNLvYST03XpBdGnhYTK78A9v_k5IOdZ4r-WmDwfYg` | ||
| 24 | - tk, _ := ut.ParseAccessToken(str) | 24 | + str := `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODM2MjQ3MTYsImlzcyI6InBlcmZvcm1hbmNlIiwidXNlcklkIjozNDIyMTg1MzQwMTIyNjI0LCJjb21wYW55SWQiOjgsImNvbXBhbnlOYW1lIjoiIiwicGhvbmUiOiIxMzA2NjY2NzcxMCIsInBsYXRmb3JtSWQiOjI5LCJuYW1lIjoiIiwiYWRtaW5UeXBlIjoxfQ.JLvIwDeY6mArmQE7NGs0u01NFArhedA6MphU94z_R04` |
| 25 | + tk, err := ut.ParseAccessToken(str) | ||
| 26 | + t.Logf("err:%s", err) | ||
| 25 | t.Logf("%+v", tk) | 27 | t.Logf("%+v", tk) |
| 26 | } | 28 | } |
| 27 | func TestParsetToken2(t *testing.T) { | 29 | func TestParsetToken2(t *testing.T) { |
-
请 注册 或 登录 后发表评论