Fix termsOfUse upload in application edit page

This commit is contained in:
Yang Luo 2023-05-10 23:57:03 +08:00
parent 3c871c38df
commit e360b06d12

View File

@ -21,6 +21,7 @@ import (
"io" "io"
"mime" "mime"
"path/filepath" "path/filepath"
"strings"
"github.com/beego/beego/utils/pagination" "github.com/beego/beego/utils/pagination"
"github.com/casdoor/casdoor/object" "github.com/casdoor/casdoor/object"
@ -235,10 +236,10 @@ func (c *ApiController) UploadResource() {
user.Avatar = fileUrl user.Avatar = fileUrl
object.UpdateUser(user.GetId(), user, []string{"avatar"}, false) object.UpdateUser(user.GetId(), user, []string{"avatar"}, false)
case "termsOfUse": case "termsOfUse":
applicationId := fmt.Sprintf("admin/%s", parent) _, applicationId := util.GetOwnerAndNameFromIdNoCheck(strings.TrimRight(fullFilePath, ".html"))
app := object.GetApplication(applicationId) applicationObj := object.GetApplication(applicationId)
app.TermsOfUse = fileUrl applicationObj.TermsOfUse = fileUrl
object.UpdateApplication(applicationId, app) object.UpdateApplication(applicationId, applicationObj)
} }
c.ResponseOk(fileUrl, objectKey) c.ResponseOk(fileUrl, objectKey)