check_base_auth.go 677 B

12345678910111213141516171819202122232425262728293031
  1. package middleware
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "hongze/hongze_yb/controller/response"
  5. "hongze/hongze_yb/services/company"
  6. "hongze/hongze_yb/services/user"
  7. )
  8. // CheckBaseAuth 基本权限校验
  9. func CheckBaseAuth() gin.HandlerFunc {
  10. return func(c *gin.Context) {
  11. userInfo := user.GetInfoByClaims(c)
  12. ok, checkInfo, _, err := company.CheckBaseFiccPermission(userInfo.CompanyID, int(userInfo.UserID))
  13. if err != nil {
  14. response.FailMsg("用户权限验证失败", "CheckBaseAuth-用户权限验证失败" + err.Error(), c)
  15. c.Abort()
  16. return
  17. }
  18. if !ok {
  19. response.AuthError(checkInfo, "暂无权限", c)
  20. c.Abort()
  21. return
  22. }
  23. c.Next()
  24. }
  25. }