filter.go 638 B

12345678910111213141516171819202122232425262728
  1. package routers
  2. import (
  3. "Cold_WorkOrder/Nats"
  4. "Cold_WorkOrder/lib"
  5. "Cold_WorkOrder/models/Account"
  6. "github.com/beego/beego/v2/server/web/context"
  7. )
  8. func FilterRBAC(ctx *context.Context) {
  9. b_, User_r, T_pid := Nats.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 := Nats.CheckUserPermissions(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. }