广告平台(媒体使用)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mw_auth.go 475 B

4 months ago
1234567891011121314151617181920212223242526
  1. package mw
  2. import (
  3. "applet/app/e"
  4. "applet/app/svc"
  5. "github.com/gin-gonic/gin"
  6. )
  7. // 检查权限, 签名等等
  8. func Auth(c *gin.Context) {
  9. admin, err := svc.CheckUser(c)
  10. if err != nil {
  11. switch err.(type) {
  12. case e.E:
  13. err1 := err.(e.E)
  14. e.OutErr(c, err1.Code, err1.Error())
  15. return
  16. default:
  17. e.OutErr(c, e.ERR_TOKEN_AUTH, err.Error())
  18. return
  19. }
  20. }
  21. // 将当前请求的username信息保存到请求的上下文c上
  22. c.Set("admin", admin)
  23. c.Next()
  24. }