Add missing creating part of sessions on registration and login

This commit is contained in:
qowevisa 2024-11-08 17:05:03 +02:00
parent f6c226e97a
commit a0b96e25b2

View File

@ -48,6 +48,11 @@ func UserRegister(c *gin.Context) {
} }
token1 = token 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) c.SetCookie(consts.COOKIE_SESSION, token1.Val, 3600, "/", "localhost", false, true)
acc := types.Account{ acc := types.Account{
ID: dbUser.ID, ID: dbUser.ID,
@ -100,6 +105,11 @@ func UserLogin(c *gin.Context) {
} }
token1 = token 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) c.SetCookie(consts.COOKIE_SESSION, token1.Val, 3600, "/", "localhost", false, true)
acc := types.Account{ acc := types.Account{
ID: foundUser.ID, ID: foundUser.ID,