Feat: session db methods and try at tx
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user