filter.go 672 B

12345678910111213141516171819202122232425262728
  1. package routers
  2. import (
  3. "Cold_GoodsOrder/Nats/NatsServer"
  4. "Cold_GoodsOrder/lib"
  5. "Cold_GoodsOrder/models/Account"
  6. "github.com/beego/beego/v2/server/web/context"
  7. )
  8. func RBACFilter(ctx *context.Context) {
  9. b_, User_r, T_pid := NatsServer.Verification(ctx.GetCookie("User_tokey"), ctx.Input.Query("User_tokey"))
  10. if !b_ {
  11. ctx.Output.JSON(lib.JSONS{Code: 201, Msg: "请重新登陆!"}, true, false)
  12. return
  13. }
  14. Account.User_r = &User_r
  15. Account.T_pid = &T_pid
  16. flag := NatsServer.CheckUserPermissions(Account.User_r.T_power, ctx.Request.URL.Path)
  17. if !flag {
  18. data := lib.JSONS{Code: 202, Msg: "无权访问!"}
  19. ctx.Output.JSON(data, true, false)
  20. return
  21. }
  22. }