From 9240d5e0521203031339766fda169662b2761520 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Sun, 17 Mar 2024 19:24:13 +0100 Subject: [PATCH] Verbose debug printing in login endpoint --- backend/internal/handlers/handlers_user_related.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/internal/handlers/handlers_user_related.go b/backend/internal/handlers/handlers_user_related.go index e90abd0..c1c8abe 100644 --- a/backend/internal/handlers/handlers_user_related.go +++ b/backend/internal/handlers/handlers_user_related.go @@ -57,9 +57,11 @@ func (gs *GState) Login(c *fiber.Ctx) error { // The body type is identical to a NewUser u := new(types.NewUser) if err := c.BodyParser(u); err != nil { + println("Error parsing body") return c.Status(400).SendString(err.Error()) } + println("Username:", u.Username) if !gs.Db.CheckUser(u.Username, u.Password) { println("User not found") return c.SendStatus(fiber.StatusUnauthorized) @@ -74,13 +76,16 @@ func (gs *GState) Login(c *fiber.Ctx) error { // Create token token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) + println("Token created for user:", u.Username) // Generate encoded token and send it as response. t, err := token.SignedString([]byte("secret")) if err != nil { + println("Error signing token") return c.SendStatus(fiber.StatusInternalServerError) } + println("Successfully signed token for user:", u.Username) return c.JSON(fiber.Map{"token": t}) }