Move time.Hour as SESSION_DURATION constant
This commit is contained in:
parent
29bf1427a0
commit
21dc84a29c
|
@ -9,13 +9,15 @@ import (
|
||||||
"git.qowevisa.me/Qowevisa/fin-check-api/db"
|
"git.qowevisa.me/Qowevisa/fin-check-api/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const SESSION_DURATION = 24 * time.Hour
|
||||||
|
|
||||||
func CreateSessionFromToken(token string, userID uint) error {
|
func CreateSessionFromToken(token string, userID uint) error {
|
||||||
sessionID := getSessionIDFromToken(token)
|
sessionID := getSessionIDFromToken(token)
|
||||||
dbc := db.Connect()
|
dbc := db.Connect()
|
||||||
session := &db.Session{
|
session := &db.Session{
|
||||||
ID: string(sessionID),
|
ID: string(sessionID),
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
ExpireAt: time.Now().Add(time.Hour),
|
ExpireAt: time.Now().Add(SESSION_DURATION),
|
||||||
}
|
}
|
||||||
if err := dbc.Create(session).Error; err != nil {
|
if err := dbc.Create(session).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue
Block a user