diff --git a/modules/context/auth.go b/modules/context/auth.go index c844040d7..48a23e421 100755 --- a/modules/context/auth.go +++ b/modules/context/auth.go @@ -135,7 +135,7 @@ func Toggle(options *ToggleOptions) macaron.Handler { } if ctx.User.WechatOpenId == "" { ctx.SetCookie("redirect_to", setting.AppSubURL+ctx.Req.URL.RequestURI(), 0, setting.AppSubURL) - ctx.Redirect(setting.AppSubURL + "/explore/users") + ctx.Redirect(setting.AppSubURL + "/authentication/wechat/bind") } } diff --git a/routers/authentication/wechat.go b/routers/authentication/wechat.go index 4362b251e..866825fce 100644 --- a/routers/authentication/wechat.go +++ b/routers/authentication/wechat.go @@ -2,6 +2,7 @@ package authentication import ( "code.gitea.io/gitea/modules/auth/wechat" + "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/redis/redis_client" @@ -13,6 +14,8 @@ import ( "time" ) +const tplBindPage base.TplName = "repo/wx_autorize" + type QRCodeResponse struct { Url string Ticket string @@ -77,6 +80,11 @@ func UnbindWechat(ctx *context.Context) { }) } +// GetBindPage +func GetBindPage(ctx *context.Context) { + ctx.HTML(200, tplBindPage) +} + func createQRCode4Bind(userId int64) (*QRCodeResponse, error) { sceneStr := gouuid.NewV4().String() r := wechat.GetWechatQRCode4Bind(sceneStr) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 7fc5fa671..213c21733 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -397,6 +397,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/qrCode4Bind", authentication.GetQRCode4Bind) m.Get("/bindStatus", authentication.GetBindStatus) m.Post("/unbind", authentication.UnbindWechat) + m.Get("/bind", authentication.GetBindPage) }, reqSignIn) m.Group("/user/settings", func() {