Browse Source

#1494

add default wechat bind page
tags/v1.22.2.2^2
Gitea 3 years ago
parent
commit
09c3d777d6
3 changed files with 10 additions and 1 deletions
  1. +1
    -1
      modules/context/auth.go
  2. +8
    -0
      routers/authentication/wechat.go
  3. +1
    -0
      routers/routes/routes.go

+ 1
- 1
modules/context/auth.go View File

@@ -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")
}
}



+ 8
- 0
routers/authentication/wechat.go View File

@@ -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)


+ 1
- 0
routers/routes/routes.go View File

@@ -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() {


Loading…
Cancel
Save