fix: issues
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package middlewares
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"backend/pkg/pg"
|
||||
@@ -14,9 +17,6 @@ import (
|
||||
)
|
||||
|
||||
func (f *Middlewares) WeChatAuthUserInfo(c fiber.Ctx) error {
|
||||
log.WithField("module", "middleware.WeChatAuthUserInfo").Debug("Begin")
|
||||
defer log.WithField("module", "middleware.WeChatAuthUserInfo").Debug("END")
|
||||
|
||||
// 如果请求存在 Authorization 头,则跳过
|
||||
if len(c.GetReqHeaders()["Authorization"]) != 0 {
|
||||
return c.Next()
|
||||
@@ -81,6 +81,13 @@ func (f *Middlewares) WeChatAuthUserInfo(c fiber.Ctx) error {
|
||||
return errors.Wrap(err, "failed to create token")
|
||||
}
|
||||
|
||||
// TODO: send html with jwt token
|
||||
return c.SendString(jwtToken)
|
||||
b, err := os.ReadFile(filepath.Join(f.storagePath.Asset, "index.html"))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to read file")
|
||||
}
|
||||
|
||||
html := strings.ReplaceAll(string(b), "{{JWT}}", jwtToken)
|
||||
|
||||
c.Set("Content-Type", "text/html")
|
||||
return c.SendString(html)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user