From 5763b3e46366e06ad5458cfc265e880af495568c Mon Sep 17 00:00:00 2001 From: wangjr Date: Thu, 24 Feb 2022 15:42:58 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E6=9A=82=E6=97=B6?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=E4=B8=8D=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/js/components/MinioUploader.vue | 2 +- web_src/js/components/ObsUploader.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web_src/js/components/MinioUploader.vue b/web_src/js/components/MinioUploader.vue index 85f1c084a..0699f957e 100755 --- a/web_src/js/components/MinioUploader.vue +++ b/web_src/js/components/MinioUploader.vue @@ -81,7 +81,7 @@ export default { dictInvalidFileType: this.dropzoneParams.data('invalid-input-type'), dictFileTooBig: this.dropzoneParams.data('file-too-big'), dictRemoveFile: this.dropzoneParams.data('remove-file'), - // previewTemplate + previewTemplate }); dropzoneUploader.on('addedfile', (file) => { setTimeout(() => { diff --git a/web_src/js/components/ObsUploader.vue b/web_src/js/components/ObsUploader.vue index 18b9a61bd..b20594b86 100755 --- a/web_src/js/components/ObsUploader.vue +++ b/web_src/js/components/ObsUploader.vue @@ -82,7 +82,7 @@ export default { dictInvalidFileType: this.dropzoneParams.data('invalid-input-type'), dictFileTooBig: this.dropzoneParams.data('file-too-big'), dictRemoveFile: this.dropzoneParams.data('remove-file'), - // previewTemplate + previewTemplate }); dropzoneUploader.on('addedfile', (file) => { setTimeout(() => { From c28ea2ed79a0d21d5ec734109c17e8676a1f9a79 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 24 Feb 2022 16:29:49 +0800 Subject: [PATCH 2/6] #1574 fix bug --- routers/routes/routes.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 21c5e2e79..5be7fc10a 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -993,7 +993,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("", reqRepoCloudBrainReader, repo.CloudBrainShow) }) m.Group("/:jobid", func() { - m.Get("/debug", reqWechatBind,cloudbrain.AdminOrJobCreaterRight, repo.CloudBrainDebug) + m.Get("/debug", reqWechatBind, cloudbrain.AdminOrJobCreaterRight, repo.CloudBrainDebug) m.Post("/commit_image", cloudbrain.AdminOrJobCreaterRight, bindIgnErr(auth.CommitImageCloudBrainForm{}), repo.CloudBrainCommitImage) m.Post("/stop", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainStop) m.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainDel) @@ -1061,11 +1061,11 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/:jobid", func() { m.Get("", reqRepoCloudBrainReader, repo.NotebookShow) m.Get("/debug", cloudbrain.AdminOrJobCreaterRight, repo.NotebookDebug2) - m.Post("/:action", reqRepoCloudBrainWriter, repo.NotebookManage) + m.Post("/:action", reqWechatBindForApi, reqRepoCloudBrainWriter, repo.NotebookManage) m.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.NotebookDel) }) - m.Get("/create", reqRepoCloudBrainWriter, repo.NotebookNew) - m.Post("/create", reqRepoCloudBrainWriter, bindIgnErr(auth.CreateModelArtsNotebookForm{}), repo.Notebook2Create) + m.Get("/create", reqWechatBind, reqRepoCloudBrainWriter, repo.NotebookNew) + m.Post("/create", reqWechatBind, reqRepoCloudBrainWriter, bindIgnErr(auth.CreateModelArtsNotebookForm{}), repo.Notebook2Create) }) m.Group("/train-job", func() { From 18083c60da83643ba5538f36fd78f342a4844e42 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 24 Feb 2022 16:35:48 +0800 Subject: [PATCH 3/6] #1573 fix bug --- routers/routes/routes.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 5be7fc10a..b1058058d 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -1075,8 +1075,8 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("/stop", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.TrainJobStop) m.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.TrainJobDel) m.Get("/model_download", cloudbrain.AdminOrJobCreaterRight, repo.ModelDownload) - m.Get("/create_version", cloudbrain.AdminOrJobCreaterRight, repo.TrainJobNewVersion) - m.Post("/create_version", cloudbrain.AdminOrJobCreaterRight, bindIgnErr(auth.CreateModelArtsTrainJobForm{}), repo.TrainJobCreateVersion) + m.Get("/create_version", reqWechatBind, cloudbrain.AdminOrJobCreaterRight, repo.TrainJobNewVersion) + m.Post("/create_version", reqWechatBind, cloudbrain.AdminOrJobCreaterRight, bindIgnErr(auth.CreateModelArtsTrainJobForm{}), repo.TrainJobCreateVersion) }) m.Get("/create", reqWechatBind, reqRepoCloudBrainWriter, repo.TrainJobNew) m.Post("/create", reqWechatBind, reqRepoCloudBrainWriter, bindIgnErr(auth.CreateModelArtsTrainJobForm{}), repo.TrainJobCreate) From e36e20bf4048fa77239b97271316a97fa4192039 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 24 Feb 2022 17:41:51 +0800 Subject: [PATCH 4/6] #1573 fix bug --- modules/context/context.go | 15 +++++++++++++++ routers/repo/modelarts.go | 1 + routers/routes/routes.go | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/context/context.go b/modules/context/context.go index 65f4b3f5d..baaa69754 100755 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -354,3 +354,18 @@ func Contexter() macaron.Handler { c.Map(ctx) } } + +// CheckWechatBind +func (ctx *Context) CheckWechatBind() { + if !setting.WechatAuthSwitch { + return + } + redirectUrl := ctx.Query("redirect_to") + if redirectUrl == "" { + redirectUrl = ctx.Req.URL.RequestURI() + } + ctx.SetCookie("redirect_to", setting.AppSubURL+redirectUrl, 0, setting.AppSubURL) + ctx.JSON(200, map[string]string{ + "WechatRedirectUrl": setting.AppSubURL + "/authentication/wechat/bind", + }) +} diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 60e58ab52..ced1362c2 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -344,6 +344,7 @@ func NotebookManage(ctx *context.Context) { break } } else if action == models.ActionRestart { + ctx.CheckWechatBind() if task.Status != string(models.ModelArtsStopped) && task.Status != string(models.ModelArtsStartFailed) && task.Status != string(models.ModelArtsCreateFailed) { log.Error("the job(%s) is not stopped", task.JobName, ctx.Data["MsgID"]) resultCode = "-1" diff --git a/routers/routes/routes.go b/routers/routes/routes.go index b1058058d..9dc69828c 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -1061,7 +1061,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/:jobid", func() { m.Get("", reqRepoCloudBrainReader, repo.NotebookShow) m.Get("/debug", cloudbrain.AdminOrJobCreaterRight, repo.NotebookDebug2) - m.Post("/:action", reqWechatBindForApi, reqRepoCloudBrainWriter, repo.NotebookManage) + m.Post("/:action", reqRepoCloudBrainWriter, repo.NotebookManage) m.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.NotebookDel) }) m.Get("/create", reqWechatBind, reqRepoCloudBrainWriter, repo.NotebookNew) From d17b10ef167d6bb5953e47af9d234735221299a2 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 24 Feb 2022 17:47:59 +0800 Subject: [PATCH 5/6] #1573 fix bug --- routers/repo/modelarts.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index ced1362c2..ebba2e95a 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -345,6 +345,9 @@ func NotebookManage(ctx *context.Context) { } } else if action == models.ActionRestart { ctx.CheckWechatBind() + if ctx.Written() { + return + } if task.Status != string(models.ModelArtsStopped) && task.Status != string(models.ModelArtsStartFailed) && task.Status != string(models.ModelArtsCreateFailed) { log.Error("the job(%s) is not stopped", task.JobName, ctx.Data["MsgID"]) resultCode = "-1" From 05ed9d9233ec0ca4eb998eaf4785a7c1d2cbf394 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 24 Feb 2022 17:54:03 +0800 Subject: [PATCH 6/6] #1573 fix bug --- modules/context/context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/context/context.go b/modules/context/context.go index baaa69754..2c935881c 100755 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -357,7 +357,7 @@ func Contexter() macaron.Handler { // CheckWechatBind func (ctx *Context) CheckWechatBind() { - if !setting.WechatAuthSwitch { + if !setting.WechatAuthSwitch || ctx.User.IsBindWechat() { return } redirectUrl := ctx.Query("redirect_to")