fix: issues
Some checks failed
build quyun / Build (push) Failing after 1m21s

This commit is contained in:
2025-12-22 12:04:38 +08:00
parent ed48ec46a8
commit 4704cf6949
2 changed files with 16 additions and 9 deletions

View File

@@ -22,7 +22,9 @@ func (f *Middlewares) AuthFrontend(ctx fiber.Ctx) error {
if strings.HasPrefix(ctx.Path(), "/v1/posts/") && strings.HasSuffix(ctx.Path(), "show") {
return ctx.Next()
}
if strings.HasPrefix(ctx.Path(), "/v1/posts/") && strings.HasSuffix(ctx.Path(), "play") {
token := ctx.Get("Authorization")
if token == "" && strings.HasPrefix(ctx.Path(), "/v1/posts/") && strings.HasSuffix(ctx.Path(), "play") {
return ctx.Next()
}
@@ -47,7 +49,6 @@ func (f *Middlewares) AuthFrontend(ctx fiber.Ctx) error {
fullUrl = u.String()
// 仅使用 Header 的 Bearer Token前端 localStorage 存储,随请求透传)。
token := ctx.Get("Authorization")
if token == "" {
log.Infof("auth redirect_uri: %s", fullUrl)
if ctx.XHR() {
@@ -73,6 +74,7 @@ func (f *Middlewares) AuthFrontend(ctx fiber.Ctx) error {
}
ctx.Locals("user", user)
log.Infof("jwt login user id: %d", user.ID)
return ctx.Next()
}