From fbf539b0bea50f1cc2864fb9d1989c9ce4041d72 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 13 Jan 2022 15:15:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/ai_model_manage.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/routers/repo/ai_model_manage.go b/routers/repo/ai_model_manage.go index 79f69beea..be1769625 100644 --- a/routers/repo/ai_model_manage.go +++ b/routers/repo/ai_model_manage.go @@ -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 }