Browse Source

权限修正

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.1.2
zouap 4 years ago
parent
commit
fbf539b0be
1 changed files with 6 additions and 5 deletions
  1. +6
    -5
      routers/repo/ai_model_manage.go

+ 6
- 5
routers/repo/ai_model_manage.go View File

@@ -209,7 +209,8 @@ func DeleteModel(ctx *context.Context) {
})
}
}
func isCanDeleteOrDownload(ctx *context.Context, model *models.AiModelManage) bool {

func isCanDelete(ctx *context.Context, model *models.AiModelManage) bool {
if ctx.User.IsAdmin || ctx.User.ID == model.UserId {
return true
}
@@ -222,7 +223,7 @@ func isCanDeleteOrDownload(ctx *context.Context, model *models.AiModelManage) bo
func deleteModelByID(ctx *context.Context, id string) error {
log.Info("delete model start. id=" + id)
model, err := models.QueryModelById(id)
if !isCanDeleteOrDownload(ctx, model) {
if !isCanDelete(ctx, model) {
return errors.New(ctx.Tr("repo.model_noright"))
}
if err == nil {
@@ -278,7 +279,7 @@ func DownloadMultiModelFile(ctx *context.Context) {
ctx.ServerError("no such model:", err)
return
}
if !isCanDeleteOrDownload(ctx, task) {
if !isOper(ctx, task.UserId) {
ctx.ServerError("no right.", errors.New(ctx.Tr("repo.model_noright")))
return
}
@@ -528,7 +529,7 @@ func isOper(ctx *context.Context, modelUserId int64) bool {
if ctx.User == nil {
return false
}
if ctx.User.IsAdmin || ctx.Repo.IsOwner() || ctx.User.ID == modelUserId {
if ctx.User.IsAdmin || ctx.User.ID == modelUserId {
return true
}
return false
@@ -607,7 +608,7 @@ func ModifyModelInfo(ctx *context.Context) {
ctx.ServerError("no such model:", err)
return
}
if !isCanDeleteOrDownload(ctx, task) {
if !isOper(ctx, task.UserId) {
ctx.ServerError("no right.", errors.New(ctx.Tr("repo.model_noright")))
return
}


Loading…
Cancel
Save