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 }