智慧食堂
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.

27 lines
478 B

  1. package mw
  2. import (
  3. svc2 "applet/app/admin/svc"
  4. "applet/app/e"
  5. "github.com/gin-gonic/gin"
  6. )
  7. // Auth 检查签名
  8. func Auth(c *gin.Context) {
  9. admin, err := svc2.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. }