重构代码结构与认证体系,集成异步任务消费者
This commit is contained in:
@@ -2,12 +2,14 @@ package handlers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"platform/pkg/env"
|
||||
"platform/web/auth"
|
||||
"platform/web/services"
|
||||
"regexp"
|
||||
"strconv"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
type VerifierReq struct {
|
||||
@@ -17,7 +19,7 @@ type VerifierReq struct {
|
||||
|
||||
func SmsCode(c *fiber.Ctx) error {
|
||||
|
||||
_, err := auth.Protect(c, []auth.PayloadType{auth.PayloadInternalServer}, []string{})
|
||||
_, err := auth.GetAuthCtx(c).PermitInternalClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -48,3 +50,19 @@ func SmsCode(c *fiber.Ctx) error {
|
||||
// 发送成功
|
||||
return nil
|
||||
}
|
||||
|
||||
func DebugGetSmsCode(c *fiber.Ctx) error {
|
||||
if env.RunMode != env.RunModeDev {
|
||||
return fiber.NewError(fiber.StatusForbidden, "not allowed")
|
||||
}
|
||||
|
||||
code, err := services.Verifier.GetSms(c.Context(), c.Params("phone"))
|
||||
if err != nil {
|
||||
if errors.Is(err, redis.Nil) {
|
||||
return c.SendString("还没有验证码")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return c.SendString(code)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user