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 } }