fix: mp verify
This commit is contained in:
@@ -54,11 +54,13 @@ func Provide(opts ...opt.Option) error {
|
|||||||
auth *auth,
|
auth *auth,
|
||||||
pays *pays,
|
pays *pays,
|
||||||
posts *posts,
|
posts *posts,
|
||||||
|
weChat *weChat,
|
||||||
) (contracts.HttpRoute, error) {
|
) (contracts.HttpRoute, error) {
|
||||||
obj := &Routes{
|
obj := &Routes{
|
||||||
auth: auth,
|
auth: auth,
|
||||||
pays: pays,
|
pays: pays,
|
||||||
posts: posts,
|
posts: posts,
|
||||||
|
weChat: weChat,
|
||||||
}
|
}
|
||||||
if err := obj.Prepare(); err != nil {
|
if err := obj.Prepare(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -68,5 +70,12 @@ func Provide(opts ...opt.Option) error {
|
|||||||
}, atom.GroupRoutes); err != nil {
|
}, atom.GroupRoutes); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := container.Container.Provide(func() (*weChat, error) {
|
||||||
|
obj := &weChat{}
|
||||||
|
|
||||||
|
return obj, nil
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,11 @@ import (
|
|||||||
|
|
||||||
// @provider contracts.HttpRoute atom.GroupRoutes
|
// @provider contracts.HttpRoute atom.GroupRoutes
|
||||||
type Routes struct {
|
type Routes struct {
|
||||||
log *log.Entry `inject:"false"`
|
log *log.Entry `inject:"false"`
|
||||||
auth *auth
|
auth *auth
|
||||||
pays *pays
|
pays *pays
|
||||||
posts *posts
|
posts *posts
|
||||||
|
weChat *weChat
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Routes) Prepare() error {
|
func (r *Routes) Prepare() error {
|
||||||
@@ -74,4 +75,10 @@ func (r *Routes) Register(router fiber.Router) {
|
|||||||
Local[*model.Users]("user"),
|
Local[*model.Users]("user"),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
// 注册路由组: weChat
|
||||||
|
router.Get("/MP_verify_:code.txt", Func1(
|
||||||
|
r.weChat.Verify,
|
||||||
|
PathParam[string]("code"),
|
||||||
|
))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
13
backend/app/http/wechat.go
Normal file
13
backend/app/http/wechat.go
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package http
|
||||||
|
|
||||||
|
import "github.com/gofiber/fiber/v3"
|
||||||
|
|
||||||
|
// @provider
|
||||||
|
type weChat struct{}
|
||||||
|
|
||||||
|
// Verify
|
||||||
|
// @Router /MP_verify_:code.txt [get]
|
||||||
|
// @Bind code path
|
||||||
|
func (*weChat) Verify(ctx fiber.Ctx, code string) error {
|
||||||
|
return ctx.SendString(code)
|
||||||
|
}
|
||||||
@@ -15,6 +15,10 @@ func (f *Middlewares) Auth(ctx fiber.Ctx) error {
|
|||||||
return ctx.Next()
|
return ctx.Next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(ctx.Path(), "/MP_verify_") {
|
||||||
|
return ctx.Next()
|
||||||
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(ctx.Path(), "/v1/admin/") {
|
if strings.HasPrefix(ctx.Path(), "/v1/admin/") {
|
||||||
token := ctx.Get("Authorization")
|
token := ctx.Get("Authorization")
|
||||||
if token == "" {
|
if token == "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user