package routers

import (
	"Cold_GoodsOrder/Nats/NatsServer"
	"Cold_GoodsOrder/lib"
	"github.com/beego/beego/v2/server/web/context"
)

func FilterRBAC(ctx *context.Context) {

	b_, admin := NatsServer.Verification(ctx.GetCookie("User_tokey"), ctx.Input.Query("User_tokey"))
	if !b_ {
		ctx.Output.JSON(lib.JSONS{Code: 201, Msg: "请重新登陆!"}, true, false)
		return
	}

	flag := NatsServer.CheckUserPermissions(admin.T_power, ctx.Request.URL.Path)

	if !flag {
		data := lib.JSONS{Code: 201, Msg: "无权访问!"}
		ctx.Output.JSON(data, true, false)
		return
	}

}
