feat: add parameter v0 for Casbin APIs (#1315)

This commit is contained in:
会思考的下丘脑
2022-11-23 22:39:17 +08:00
committed by GitHub
parent 7e756b8ee2
commit 56ff06bbea
2 changed files with 6 additions and 18 deletions

View File

@ -21,12 +21,6 @@ import (
)
func (c *ApiController) Enforce() {
userId := c.GetSessionUsername()
if userId == "" {
c.ResponseError(c.T("EnforcerErr.SignInFirst"))
return
}
var permissionRule object.PermissionRule
err := json.Unmarshal(c.Ctx.Input.RequestBody, &permissionRule)
if err != nil {
@ -34,17 +28,11 @@ func (c *ApiController) Enforce() {
return
}
c.Data["json"] = object.Enforce(userId, &permissionRule)
c.Data["json"] = object.Enforce(&permissionRule)
c.ServeJSON()
}
func (c *ApiController) BatchEnforce() {
userId := c.GetSessionUsername()
if userId == "" {
c.ResponseError(c.T("EnforcerErr.SignInFirst"))
return
}
var permissionRules []object.PermissionRule
err := json.Unmarshal(c.Ctx.Input.RequestBody, &permissionRules)
if err != nil {
@ -52,7 +40,7 @@ func (c *ApiController) BatchEnforce() {
return
}
c.Data["json"] = object.BatchEnforce(userId, permissionRules)
c.Data["json"] = object.BatchEnforce(permissionRules)
c.ServeJSON()
}