From c9f1c34c2aca4e774d8f1344f61d6705655ea91d Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 25 Nov 2021 15:09:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=AD=E7=BB=83=E4=BD=9C=E4=B8=9A=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E6=9D=83=E9=99=90=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/repo/modelarts.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 484715cb5..1243a7586 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -1320,12 +1320,16 @@ func canUserCreateTrainJob(uid int64) (bool, error) { return org.IsOrgMember(uid) } func canUserCreateTrainJobVersion(ctx *context.Context, userID int64) (bool, error) { - if ctx.User.ID == userID || ctx.User.IsAdmin { - canNewJob := true - return canNewJob, nil + if ctx == nil || ctx.User == nil { + log.Error("user unlogin!") + return false, nil + } + if userID != ctx.User.ID || !ctx.User.IsAdmin { + log.Error("Only user itself and admin can new trainjob!") + // ctx.ServerError("Only user itself and admin can new trainjob!", nil) + return false, nil } else { - canNewJob := false - return canNewJob, nil + return true, nil } }