Skip to content

Commit c0ed5aa

Browse files
fix-GetUserID
1 parent de25870 commit c0ed5aa

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

bootstrap/init.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ func registerMiddlewares(app *fiber.App) {
4949
}
5050

5151
func GetUser(c *fiber.Ctx) error {
52-
user, err := models.GetUser(c)
52+
userID, err := models.GetUserID(c)
5353
if err != nil {
5454
return err
5555
}
56-
c.Locals("user", user)
56+
c.Locals("user_id", userID)
5757

5858
return c.Next()
5959
}
@@ -69,15 +69,15 @@ func MyLogger(c *fiber.Ctx) error {
6969
}
7070

7171
latency := time.Since(startTime).Milliseconds()
72-
user := c.Locals("user").(*models.User)
72+
userID := c.Locals("userID").(int)
7373
utils.Logger.Info("LOG : ",
7474
zap.Int("StatusCode", c.Response().StatusCode()),
7575
zap.String("Method", string(c.Method())),
7676
zap.String("OriginUrl", c.OriginalURL()),
7777
zap.String("RemoteIP", string(c.Get("X-Real-IP"))),
7878
zap.Int("Latency", int(latency)),
7979
zap.String("Error", chainErr.Error()),
80-
zap.Int("User", user.ID),
80+
zap.Int("UserID", userID),
8181
)
8282

8383
return chainErr

0 commit comments

Comments
 (0)