mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 10:45:47 +08:00
Add GetOwnerAndNameFromIdNoCheck() to fix bug.
This commit is contained in:
parent
ea8971ff29
commit
90ec8ec787
@ -57,17 +57,17 @@ func getResource(owner string, name string) *Resource {
|
|||||||
if existed {
|
if existed {
|
||||||
return &resource
|
return &resource
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetResource(id string) *Resource {
|
func GetResource(id string) *Resource {
|
||||||
owner, name := util.GetOwnerAndNameFromId(id)
|
owner, name := util.GetOwnerAndNameFromIdNoCheck(id)
|
||||||
return getResource(owner, name)
|
return getResource(owner, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateResource(id string, resource *Resource) bool {
|
func UpdateResource(id string, resource *Resource) bool {
|
||||||
owner, name := util.GetOwnerAndNameFromId(id)
|
owner, name := util.GetOwnerAndNameFromIdNoCheck(id)
|
||||||
if getResource(owner, name) == nil {
|
if getResource(owner, name) == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,11 @@ func GetOwnerAndNameFromId(id string) (string, string) {
|
|||||||
return tokens[0], tokens[1]
|
return tokens[0], tokens[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetOwnerAndNameFromIdNoCheck(id string) (string, string) {
|
||||||
|
tokens := strings.SplitN(id, "/", 2)
|
||||||
|
return tokens[0], tokens[1]
|
||||||
|
}
|
||||||
|
|
||||||
func GenerateId() string {
|
func GenerateId() string {
|
||||||
return uuid.NewString()
|
return uuid.NewString()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user