diff --git a/cookie/backend_bolt.go b/cookie/backend_bolt.go index 74fe5c9..71cc16c 100644 --- a/cookie/backend_bolt.go +++ b/cookie/backend_bolt.go @@ -129,7 +129,9 @@ func (b *BoltBackend) ListUser(username string) (list SessionFullList, err error if err := json.Unmarshal(value, &session); err != nil { return err } - list = append(list, SessionFull{Session: Session{ID: id, SessionBase: session.SessionBase}, Agent: session.Agent}) + if !session.SessionBase.IsExpired() { + list = append(list, SessionFull{Session: Session{ID: id, SessionBase: session.SessionBase}, Agent: session.Agent}) + } } return nil }) @@ -232,7 +234,9 @@ func (b *BoltBackend) ListRevoked() (list SessionList, err error) { if err := json.Unmarshal(value, &session); err != nil { return err } - list = append(list, Session{ID: id, SessionBase: session}) + if !session.IsExpired() { + list = append(list, Session{ID: id, SessionBase: session}) + } } return nil }) diff --git a/cookie/backend_in-memory.go b/cookie/backend_in-memory.go index 5da4c1f..710ad5b 100644 --- a/cookie/backend_in-memory.go +++ b/cookie/backend_in-memory.go @@ -89,7 +89,9 @@ func (b *InMemoryBackend) ListUser(username string) (list SessionFullList, err e return } for id, session := range sessions { - list = append(list, SessionFull{Session: Session{ID: id, SessionBase: session.SessionBase}, Agent: session.Agent}) + if !session.SessionBase.IsExpired() { + list = append(list, SessionFull{Session: Session{ID: id, SessionBase: session.SessionBase}, Agent: session.Agent}) + } } return } @@ -135,7 +137,9 @@ func (b *InMemoryBackend) ListRevoked() (list SessionList, err error) { defer b.mutex.RUnlock() for id, session := range b.revoked { - list = append(list, Session{ID: id, SessionBase: session}) + if !session.IsExpired() { + list = append(list, Session{ID: id, SessionBase: session}) + } } return }