From a0b96e25b2370173af1779397051ba3303f5644b Mon Sep 17 00:00:00 2001 From: qowevisa Date: Fri, 8 Nov 2024 17:05:03 +0200 Subject: [PATCH] Add missing creating part of sessions on registration and login --- handlers/user.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/handlers/user.go b/handlers/user.go index 1cb3822..b55f036 100644 --- a/handlers/user.go +++ b/handlers/user.go @@ -48,6 +48,11 @@ func UserRegister(c *gin.Context) { } token1 = token } + err := tokens.CreateSessionFromToken(token1.Val, dbUser.ID) + if err != nil { + log.Printf("tokens.CreateSessionFromToken: %v\n", err) + c.JSON(500, types.ErrorResponse{Message: "ERROR: 1000"}) + } c.SetCookie(consts.COOKIE_SESSION, token1.Val, 3600, "/", "localhost", false, true) acc := types.Account{ ID: dbUser.ID, @@ -100,6 +105,11 @@ func UserLogin(c *gin.Context) { } token1 = token } + err := tokens.CreateSessionFromToken(token1.Val, foundUser.ID) + if err != nil { + log.Printf("tokens.CreateSessionFromToken: %v\n", err) + c.JSON(500, types.ErrorResponse{Message: "ERROR: 1000"}) + } c.SetCookie(consts.COOKIE_SESSION, token1.Val, 3600, "/", "localhost", false, true) acc := types.Account{ ID: foundUser.ID,