check_font_token.go
635 字节
package middlewares
import (
"github.com/beego/beego/v2/server/web/context"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
func CheckFontToken() func(ctx *context.Context) {
return func(ctx *context.Context) {
adminToken := ctx.Input.Header("x-font-token")
userAuth, err := (&domain.UserAuth{}).ParseAccessToken(adminToken)
if err != nil || userAuth.UserId <= 0 {
forbidden(ctx)
return
}
if userAuth.PlatformId != constant.PLATFORM_FONT_ID {
forbidden(ctx)
return
}
ctx.Input.SetData(domain.UserAuth{}, userAuth)
}
}