26 lines
668 B
Go
26 lines
668 B
Go
package domain
|
|
|
|
import "time"
|
|
|
|
// SessionID is a typed session identifier with prefix "ses_".
|
|
type SessionID string
|
|
|
|
// Session tracks a user login with device and location information.
|
|
// The session ID is embedded in the JWT token for revocation support.
|
|
type Session struct {
|
|
ID SessionID
|
|
UserID UserID
|
|
IPAddress string
|
|
UserAgent string
|
|
DeviceLabel string
|
|
LastActiveAt time.Time
|
|
ExpiresAt time.Time
|
|
RevokedAt *time.Time
|
|
CreatedAt time.Time
|
|
}
|
|
|
|
// IsActive returns true if the session has not been revoked and has not expired.
|
|
func (s *Session) IsActive() bool {
|
|
return s.RevokedAt == nil && time.Now().Before(s.ExpiresAt)
|
|
}
|