From 21dc84a29c156dd9a71ba01acbb49c0d2ada8f1f Mon Sep 17 00:00:00 2001 From: qowevisa Date: Sat, 30 Nov 2024 12:36:11 +0200 Subject: [PATCH] Move time.Hour as SESSION_DURATION constant --- tokens/sessions.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tokens/sessions.go b/tokens/sessions.go index 8d5519a..dfafd4b 100644 --- a/tokens/sessions.go +++ b/tokens/sessions.go @@ -9,13 +9,15 @@ import ( "git.qowevisa.me/Qowevisa/fin-check-api/db" ) +const SESSION_DURATION = 24 * time.Hour + func CreateSessionFromToken(token string, userID uint) error { sessionID := getSessionIDFromToken(token) dbc := db.Connect() session := &db.Session{ ID: string(sessionID), UserID: userID, - ExpireAt: time.Now().Add(time.Hour), + ExpireAt: time.Now().Add(SESSION_DURATION), } if err := dbc.Create(session).Error; err != nil { return err