feat: update middlewares

This commit is contained in:
yanghao05
2025-04-28 21:17:43 +08:00
parent 9db957e716
commit 2df1a59a20
2 changed files with 2 additions and 8 deletions

View File

@@ -15,14 +15,9 @@ func (f *Middlewares) Auth(ctx fiber.Ctx) error {
return ctx.Next()
}
uu, err := models.Users.GetByID(ctx.Context(), 1)
if err != nil {
log.WithError(err).Error("failed to get user")
return ctx.SendString("NOT OK")
if strings.HasPrefix(ctx.Path(), "/v1/admin/") {
return ctx.Next()
}
ctx.Locals("user", uu)
log.Infof("set ctx user: %d", uu.ID)
return ctx.Next()
fullUrl := string(ctx.Request().URI().FullURI())
u, err := url.Parse(fullUrl)

View File

@@ -7,7 +7,6 @@ import (
)
func (f *Middlewares) AuthAdmin(ctx fiber.Ctx) error {
return ctx.Next()
if !strings.HasPrefix(ctx.Path(), "/v1/admin") {
return ctx.Next()
}