From e360b06d12bc8ae2d451d7b956e480947350a627 Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Wed, 10 May 2023 23:57:03 +0800 Subject: [PATCH] Fix termsOfUse upload in application edit page --- controllers/resource.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/controllers/resource.go b/controllers/resource.go index 58db0523..a53e6eac 100644 --- a/controllers/resource.go +++ b/controllers/resource.go @@ -21,6 +21,7 @@ import ( "io" "mime" "path/filepath" + "strings" "github.com/beego/beego/utils/pagination" "github.com/casdoor/casdoor/object" @@ -235,10 +236,10 @@ func (c *ApiController) UploadResource() { user.Avatar = fileUrl object.UpdateUser(user.GetId(), user, []string{"avatar"}, false) case "termsOfUse": - applicationId := fmt.Sprintf("admin/%s", parent) - app := object.GetApplication(applicationId) - app.TermsOfUse = fileUrl - object.UpdateApplication(applicationId, app) + _, applicationId := util.GetOwnerAndNameFromIdNoCheck(strings.TrimRight(fullFilePath, ".html")) + applicationObj := object.GetApplication(applicationId) + applicationObj.TermsOfUse = fileUrl + object.UpdateApplication(applicationId, applicationObj) } c.ResponseOk(fileUrl, objectKey)