package admin import ( "git.icechen.cn/monorepo/backend/pkg/proto/zeus/lark" "git.icechen.cn/monorepo/backend/pkg/rpc" "github.com/gofiber/fiber/v2" ) const AuthorizationHeader = "Authorization" const UserInfoKey = "user_info" type UserInfo = *lark.InfoResponse // MiddlewareLarkAdmin 飞书管理员token校验 func MiddlewareLarkAdmin(c *fiber.Ctx) error { token := c.Get(AuthorizationHeader) response, err := lark.NewUserClient(rpc.GetServiceConn("lark")).Info(c.Context(), &lark.InfoRequest{ Token: token, }) if err != nil { return err } c.Context().SetUserValue(UserInfoKey, response) return c.Next() } // GetUserInfo 获取用户信息 func GetUserInfo(c *fiber.Ctx) UserInfo { return c.Context().UserValue(UserInfoKey).(UserInfo) }