Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update TokenGenerator data from MapClaims to interface (appleboy#146)
Hi. I want to use TokenGenerator func like below but there is a simple issue. ``` func TestAuthMiddleWare(t *testing.T) { authMiddleware := &jwt.GinJWTMiddleware{ Realm: "test Zone", Key: []byte("secret key"), Timeout: time.Hour, MaxRefresh: time.Hour, Authenticator: Authenticator, Authorizator: Authorizator, Unauthorized: Unauthorized, PayloadFunc: PayloadFunc, TokenLookup: "header:Authorization", TokenHeadName: "Bearer", TimeFunc: time.Now, } authMiddleware.MiddlewareInit() // ** cannot use User literal (type *User) as type MapClaims ** token, _, _ := authMiddleware.TokenGenerator("admin", &User{ UserName: "admin", LastName: "Bo-Yi", FirstName: "Wu", }) } func PayloadFunc(data interface{}) jwt.MapClaims { user := data.(*User) return jwt.MapClaims{ "UserName": user.UserName, "FirstName": user.FirstName, "LastName": user.LastName, } } ``` As I see it is updated at appleboy#115 appleboy#118 appleboy#126 I think TokenGenerator should use interface, not MapClaims like Authenticator and LoginHandler https://github.com/appleboy/gin-jwt/blob/c21115ccebd465511fefed0a0b9f9a4f5a08318d/auth_jwt.go#L360-L375 Can you check it?
- Loading branch information