Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateCreateSessionRequest ¶
func ValidateCreateSessionRequest(req *CreateSessionRequest) error
ValidateCreateSessionRequest validates a create session request
Types ¶
type CreateSessionRequest ¶
type CreateSessionRequest struct {
UserID string
ExpiresAt time.Time
Token string
IPAddress *string
UserAgent *string
}
CreateSessionRequest represents a request to create a new session
type Repository ¶
type Repository interface {
// Create creates a new session
Create(session *Session) error
// FindByID retrieves a session by ID
FindByID(id string) (*Session, error)
// FindByToken retrieves a session by token
FindByToken(token string) (*Session, error)
// FindByUserID retrieves all sessions for a user
FindByUserID(userID string) ([]*Session, error)
// Update updates an existing session
Update(session *Session) error
// Delete deletes a session by ID
Delete(id string) error
// DeleteByUserID deletes all sessions for a user
DeleteByUserID(userID string) error
// DeleteExpired deletes all expired sessions
DeleteExpired() error
// Count returns the total number of sessions
Count() (int, error)
// ExistsByID checks if a session exists by ID
ExistsByID(id string) (bool, error)
// ExistsByToken checks if a session exists by token
ExistsByToken(token string) (bool, error)
}
Repository defines the interface for session data access
type Session ¶
type Session struct {
ID string `json:"id"`
UserID string `json:"user_id"`
ExpiresAt time.Time `json:"expires_at"`
Token string `json:"token"`
IPAddress *string `json:"ip_address,omitempty"`
UserAgent *string `json:"user_agent,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Session represents an active user session
Click to show internal directories.
Click to hide internal directories.