| @@ -354,3 +354,18 @@ func Contexter() macaron.Handler { | |||||
| c.Map(ctx) | 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", | |||||
| }) | |||||
| } | |||||
| @@ -344,6 +344,7 @@ func NotebookManage(ctx *context.Context) { | |||||
| break | break | ||||
| } | } | ||||
| } else if action == models.ActionRestart { | } else if action == models.ActionRestart { | ||||
| ctx.CheckWechatBind() | |||||
| if task.Status != string(models.ModelArtsStopped) && task.Status != string(models.ModelArtsStartFailed) && task.Status != string(models.ModelArtsCreateFailed) { | 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"]) | log.Error("the job(%s) is not stopped", task.JobName, ctx.Data["MsgID"]) | ||||
| resultCode = "-1" | resultCode = "-1" | ||||
| @@ -1061,7 +1061,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
| m.Group("/:jobid", func() { | m.Group("/:jobid", func() { | ||||
| m.Get("", reqRepoCloudBrainReader, repo.NotebookShow) | m.Get("", reqRepoCloudBrainReader, repo.NotebookShow) | ||||
| m.Get("/debug", cloudbrain.AdminOrJobCreaterRight, repo.NotebookDebug2) | 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.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.NotebookDel) | ||||
| }) | }) | ||||
| m.Get("/create", reqWechatBind, reqRepoCloudBrainWriter, repo.NotebookNew) | m.Get("/create", reqWechatBind, reqRepoCloudBrainWriter, repo.NotebookNew) | ||||