Add tokens.SESSION_DURATION_IN_SECONDS to tokens package and made cookies sent to front and in db session duration to be in sync
This commit is contained in:
parent
39275473af
commit
4ed24ab555
|
@ -53,7 +53,7 @@ func UserRegister(c *gin.Context) {
|
|||
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, tokens.SESSION_DURATION_IN_SECONDS, "/", "localhost", false, true)
|
||||
acc := types.Account{
|
||||
ID: dbUser.ID,
|
||||
Token: token1.Val,
|
||||
|
@ -110,7 +110,7 @@ func UserLogin(c *gin.Context) {
|
|||
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, tokens.SESSION_DURATION_IN_SECONDS, "/", "localhost", false, true)
|
||||
acc := types.Account{
|
||||
ID: foundUser.ID,
|
||||
Token: token1.Val,
|
||||
|
|
|
@ -10,7 +10,8 @@ import (
|
|||
"git.qowevisa.me/Qowevisa/fin-check-api/db"
|
||||
)
|
||||
|
||||
const SESSION_DURATION = (24 * time.Hour)
|
||||
const SESSION_DURATION_IN_SECONDS = 3600
|
||||
const SESSION_DURATION = (SESSION_DURATION_IN_SECONDS * time.Second)
|
||||
|
||||
func CreateSessionFromToken(token string, userID uint) error {
|
||||
sessionID := getSessionIDFromToken(token)
|
||||
|
|
Loading…
Reference in New Issue
Block a user