services

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeCache

type FakeCache struct {
	// contains filtered or unexported fields
}

FakeCache is a test-only fake implementing core.Cache. It stores sessions in a map and exposes error fields for behavior injection.

func NewFakeCache

func NewFakeCache() *FakeCache

func (*FakeCache) Clear

func (f *FakeCache) Clear() error

func (*FakeCache) Delete

func (f *FakeCache) Delete(tokenHash string) error

func (*FakeCache) Get

func (f *FakeCache) Get(tokenHash string) (*core.Session, error)

func (*FakeCache) Len

func (f *FakeCache) Len() int

func (*FakeCache) Set

func (f *FakeCache) Set(tokenHash string, session *core.Session) error

func (*FakeCache) SetDeleteError

func (f *FakeCache) SetDeleteError(err error)

func (*FakeCache) SetGetError

func (f *FakeCache) SetGetError(err error)

Test helper methods

func (*FakeCache) SetSetError

func (f *FakeCache) SetSetError(err error)

func (*FakeCache) Stats

func (f *FakeCache) Stats() core.CacheStats

type FakeSessionStorage

type FakeSessionStorage struct {
	// contains filtered or unexported fields
}

FakeSessionStorage is a test-only fake implementing core.SessionStorage. It stores sessions in a map and exposes error fields for behavior injection.

func NewFakeSessionStorage

func NewFakeSessionStorage() *FakeSessionStorage

func (*FakeSessionStorage) CreateSession

func (f *FakeSessionStorage) CreateSession(s *core.Session) error

func (*FakeSessionStorage) DeleteExpiredSessions

func (f *FakeSessionStorage) DeleteExpiredSessions() (int, error)

func (*FakeSessionStorage) DeleteSessionByHash

func (f *FakeSessionStorage) DeleteSessionByHash(tokenHash string) error

func (*FakeSessionStorage) DeleteSessionByID

func (f *FakeSessionStorage) DeleteSessionByID(id string) error

func (*FakeSessionStorage) DeleteUserSessions

func (f *FakeSessionStorage) DeleteUserSessions(userID string) (int, error)

func (*FakeSessionStorage) GetSessionByHash

func (f *FakeSessionStorage) GetSessionByHash(tokenHash string) (*core.Session, error)

func (*FakeSessionStorage) GetSessionByID

func (f *FakeSessionStorage) GetSessionByID(id string) (*core.Session, error)

func (*FakeSessionStorage) GetUserSessions

func (f *FakeSessionStorage) GetUserSessions(userID string) ([]*core.Session, error)

func (*FakeSessionStorage) UpdateSession

func (f *FakeSessionStorage) UpdateSession(s *core.Session) error

type FakeStorageProvider

type FakeStorageProvider struct {
	*FakeSessionStorage
	// contains filtered or unexported fields
}

FakeStorageProvider is a test-only fake implementing core.StorageProvider. It combines session, user, and account storage fakes.

func NewFakeStorageProvider

func NewFakeStorageProvider() *FakeStorageProvider

func (*FakeStorageProvider) CreateAccount

func (f *FakeStorageProvider) CreateAccount(a *core.Account) error

AccountStorage implementation

func (*FakeStorageProvider) CreateUser

func (f *FakeStorageProvider) CreateUser(u *core.User) error

UserStorage implementation

func (*FakeStorageProvider) DeleteAccount

func (f *FakeStorageProvider) DeleteAccount(id string) error

func (*FakeStorageProvider) DeleteUser

func (f *FakeStorageProvider) DeleteUser(id string) error

func (*FakeStorageProvider) GetAccountByID

func (f *FakeStorageProvider) GetAccountByID(id string) (*core.Account, error)

func (*FakeStorageProvider) GetAccountByUserAndProvider

func (f *FakeStorageProvider) GetAccountByUserAndProvider(userID, providerID string) ([]*core.Account, error)

func (*FakeStorageProvider) GetUserByEmail

func (f *FakeStorageProvider) GetUserByEmail(email string) (*core.User, error)

func (*FakeStorageProvider) GetUserByID

func (f *FakeStorageProvider) GetUserByID(id string) (*core.User, error)

func (*FakeStorageProvider) UpdateAccount

func (f *FakeStorageProvider) UpdateAccount(a *core.Account) error

func (*FakeStorageProvider) UpdateUser

func (f *FakeStorageProvider) UpdateUser(u *core.User) error

type SessionManager

type SessionManager struct {
	// contains filtered or unexported fields
}

SessionManager handles both session management and authentication operations. It combines session lifecycle (create, verify, destroy) with authentication flows (signup, signin, signout) since all these operations are related to session management.

func NewSessionManager

func NewSessionManager(config core.SessionConfig, storage core.StorageProvider, cache core.Cache, passwords crypto.PasswordHandler) *SessionManager

func (*SessionManager) Create

func (sm *SessionManager) Create(userID, ip, userAgent string) (*core.CreateSessionResult, error)

func (*SessionManager) Destroy

func (sm *SessionManager) Destroy(token string) error

func (*SessionManager) DestroyAllUserSessions

func (sm *SessionManager) DestroyAllUserSessions(userID string) (int, error)

func (*SessionManager) DestroyBySessionID

func (sm *SessionManager) DestroyBySessionID(sessionID string) error

func (*SessionManager) GetSession

func (sm *SessionManager) GetSession(token string) (*core.SessionData, error)

GetSession retrieves session data by token and returns user information.

func (*SessionManager) Refresh

func (sm *SessionManager) Refresh(token string) (*core.RefreshResult, error)

Refresh extends a session's expiry time and returns a new session and token. The old token becomes invalid immediately.

func (*SessionManager) SignIn

func (sm *SessionManager) SignIn(input core.SignInInput, ipAddress, userAgent string) (*core.SignInResult, error)

SignIn authenticates a user and creates a session.

func (*SessionManager) SignOut

func (sm *SessionManager) SignOut(token string) error

SignOut destroys a session (alias for Destroy for clearer API naming).

func (*SessionManager) SignUp

func (sm *SessionManager) SignUp(input core.SignUpInput, ipAddress, userAgent string) (*core.SignUpResult, error)

SignUp creates a new user account and session.

func (*SessionManager) Verify

func (sm *SessionManager) Verify(token string) (*core.Session, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL