Fix id of "/api/get-resource" API

This commit is contained in:
Yang Luo
2023-07-23 11:33:48 +08:00
parent a6f803aff1
commit 09f40bb5ce
2 changed files with 6 additions and 1 deletions

View File

@ -16,6 +16,7 @@ package object
import ( import (
"fmt" "fmt"
"strings"
"github.com/casdoor/casdoor/util" "github.com/casdoor/casdoor/util"
"github.com/xorm-io/core" "github.com/xorm-io/core"
@ -76,6 +77,10 @@ func GetPaginationResources(owner, user string, offset, limit int, field, value,
} }
func getResource(owner string, name string) (*Resource, error) { func getResource(owner string, name string) (*Resource, error) {
if !strings.HasPrefix(name, "/") {
name = "/" + name
}
resource := Resource{Owner: owner, Name: name} resource := Resource{Owner: owner, Name: name}
existed, err := adapter.Engine.Get(&resource) existed, err := adapter.Engine.Get(&resource)
if err != nil { if err != nil {

View File

@ -156,7 +156,7 @@ func AuthzFilter(ctx *context.Context) {
urlPath := getUrlPath(ctx.Request.URL.Path) urlPath := getUrlPath(ctx.Request.URL.Path)
objOwner, objName := "", "" objOwner, objName := "", ""
if urlPath != "/api/get-app-login" { if urlPath != "/api/get-app-login" && urlPath != "/api/get-resource" {
objOwner, objName = getObject(ctx) objOwner, objName = getObject(ctx)
} }