From dcaf54a67a9c9f37ad94ad9bf5db395bca1a3876 Mon Sep 17 00:00:00 2001 From: hupeh Date: Tue, 3 Jan 2023 23:59:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20:sparkles:=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=99=BB=E5=BD=95=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/fns.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/fns.go b/app/fns.go index aa62e32..5888c08 100644 --- a/app/fns.go +++ b/app/fns.go @@ -101,6 +101,11 @@ var ErrInvalidToken = &Error{ 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 { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { token, _, _ := jwtauth.FromContext(r.Context())