fix: wechat auth
This commit is contained in:
@@ -33,9 +33,9 @@ func (ctl *Controller) Prepare() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Router /v1/auth/wechat/jump [get]
|
// @Router /auth/wechat/jump [get]
|
||||||
// @Bind redirectUri query
|
// @Bind redirectUri query
|
||||||
func (ctl *Controller) JumpToAuth(ctx fiber.Ctx, tenant, redirectUri string) error {
|
func (ctl *Controller) JumpToAuth(ctx fiber.Ctx, redirectUri string) error {
|
||||||
_, span := otel.Start(ctx.Context(), "auth.controller.wechat")
|
_, span := otel.Start(ctx.Context(), "auth.controller.wechat")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ func (ctl *Controller) JumpToAuth(ctx fiber.Ctx, tenant, redirectUri string) err
|
|||||||
query := u.Query()
|
query := u.Query()
|
||||||
query.Set("redirect", paramRedirect)
|
query.Set("redirect", paramRedirect)
|
||||||
u.RawQuery = query.Encode()
|
u.RawQuery = query.Encode()
|
||||||
u.Path = "/v1/auth/wechat/login/" + tenant
|
u.Path = "/auth/wechat/login"
|
||||||
fullUrl := u.String()
|
fullUrl := u.String()
|
||||||
|
|
||||||
ctl.log.WithField("module", "middleware.SilentAuth").Debug("redirect_uri: ", fullUrl)
|
ctl.log.WithField("module", "middleware.SilentAuth").Debug("redirect_uri: ", fullUrl)
|
||||||
@@ -67,11 +67,11 @@ func (ctl *Controller) JumpToAuth(ctx fiber.Ctx, tenant, redirectUri string) err
|
|||||||
return ctx.Redirect().To(to.String())
|
return ctx.Redirect().To(to.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Router /v1/auth/login [get]
|
// @Router /auth/login [get]
|
||||||
// @Bind code query
|
// @Bind code query
|
||||||
// @Bind state query
|
// @Bind state query
|
||||||
// @Bind redirectUri query
|
// @Bind redirectUri query
|
||||||
func (ctl *Controller) Login(ctx fiber.Ctx, code, state, tenant, redirectUri string) error {
|
func (ctl *Controller) Login(ctx fiber.Ctx, code, state, redirectUri string) error {
|
||||||
ctl.log.Debugf("code: %s, state: %s", code, state)
|
ctl.log.Debugf("code: %s, state: %s", code, state)
|
||||||
|
|
||||||
// get the openid
|
// get the openid
|
||||||
|
|||||||
@@ -28,15 +28,13 @@ func (r *Routes) Name() string {
|
|||||||
|
|
||||||
func (r *Routes) Register(router fiber.Router) {
|
func (r *Routes) Register(router fiber.Router) {
|
||||||
// 注册路由组: Controller
|
// 注册路由组: Controller
|
||||||
router.Get("/v1/auth/wechat/jump/:tenant", Func2(
|
router.Get("/auth/wechat/jump", Func1(
|
||||||
r.controller.JumpToAuth,
|
r.controller.JumpToAuth,
|
||||||
Path[string]("tenant"),
|
|
||||||
QueryParam[string]("redirectUri"),
|
QueryParam[string]("redirectUri"),
|
||||||
))
|
))
|
||||||
|
|
||||||
router.Get("/v1/auth/login/:tenant", Func4(
|
router.Get("/auth/login", Func3(
|
||||||
r.controller.Login,
|
r.controller.Login,
|
||||||
Path[string]("tenant"),
|
|
||||||
QueryParam[string]("code"),
|
QueryParam[string]("code"),
|
||||||
QueryParam[string]("state"),
|
QueryParam[string]("state"),
|
||||||
QueryParam[string]("redirectUri"),
|
QueryParam[string]("redirectUri"),
|
||||||
|
|||||||
Reference in New Issue
Block a user