Manage session time fields centrally

This commit is contained in:
Nick Meves
2021-06-21 21:54:52 -07:00
parent 7e80e5596b
commit 7fa6d2d024
11 changed files with 91 additions and 64 deletions
+1 -2
View File
@@ -36,8 +36,7 @@ type SessionStore struct {
// within Cookies set on the HTTP response writer
func (s *SessionStore) Save(rw http.ResponseWriter, req *http.Request, ss *sessions.SessionState) error {
if ss.CreatedAt == nil || ss.CreatedAt.IsZero() {
now := time.Now()
ss.CreatedAt = &now
ss.CreatedAtNow()
}
value, err := s.cookieForSession(ss)
if err != nil {
+1 -2
View File
@@ -30,8 +30,7 @@ func NewManager(store Store, cookieOpts *options.Cookie) *Manager {
// from the persistent data store.
func (m *Manager) Save(rw http.ResponseWriter, req *http.Request, s *sessions.SessionState) error {
if s.CreatedAt == nil || s.CreatedAt.IsZero() {
now := time.Now()
s.CreatedAt = &now
s.CreatedAtNow()
}
tckt, err := decodeTicketFromRequest(req, m.Options)