Feat: session db methods and try at tx

This commit is contained in:
Grail Finder
2025-07-02 16:47:17 +03:00
parent 8d159baad7
commit a438d5b665
4 changed files with 63 additions and 9 deletions

View File

@ -12,7 +12,6 @@ import (
"html/template"
"net/http"
"strings"
"time"
)
func abortWithError(w http.ResponseWriter, msg string) {
@ -142,11 +141,12 @@ func makeCookie(username string, remote string) (*http.Cookie, error) {
// Create a new random session token
// sessionToken := xid.New().String()
sessionToken := "sessionprefix_" + username
expiresAt := time.Now().Add(time.Duration(cfg.SessionLifetime) * time.Second)
// expiresAt := time.Now().Add(time.Duration(cfg.SessionLifetime) * time.Second)
// Set the token in the session map, along with the session information
session := &models.Session{
Username: username,
Expiry: expiresAt,
Username: username,
CookieToken: sessionToken,
Lifetime: uint32(cfg.SessionLifetime / 60),
}
cookieName := "session_token"
// hmac to protect cookies