From e36e20bf4048fa77239b97271316a97fa4192039 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 24 Feb 2022 17:41:51 +0800 Subject: [PATCH] #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)