|
|
@ -101,6 +101,11 @@ var ErrInvalidToken = &Error{ |
|
|
|
Message: "错误令牌", |
|
|
|
Message: "错误令牌", |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func UserTokenFromContext(ctx context.Context) (*UserToken, bool) { |
|
|
|
|
|
|
|
ut, ok := ctx.Value("USER_TOKEN").(*UserToken) |
|
|
|
|
|
|
|
return ut, ok |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func CheckAuthToken(next http.Handler) http.Handler { |
|
|
|
func CheckAuthToken(next http.Handler) http.Handler { |
|
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
|
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
|
|
|
token, _, _ := jwtauth.FromContext(r.Context()) |
|
|
|
token, _, _ := jwtauth.FromContext(r.Context()) |
|
|
|