store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	TxKey contextKey = "store.tx.state"
	DbKey contextKey = "store.tx.db"
)
View Source
const (
	ConstraintUserEmail    = "unique_user_email"
	ConstraintUserUsername = "unique_user_username"
)

Variables

View Source
var (
	ErrUserNotFound           = errors.New("user not found")
	ErrSessionNotFound        = errors.New("session not found")
	ErrorAuthProviderNotFound = errors.New("auth_provider not found")
	ErrRefreshTokenNotFound   = errors.New("refresh_token not found")
)

Functions

func IsUniqueViolation

func IsUniqueViolation(err error, constraint string) bool

func NormalizeUsername

func NormalizeUsername(u string) string

Types

type Config

type Config struct {
	Host     string `env:"POSTGRESQL_HOST, required"`
	Port     int    `env:"POSTGRESQL_PORT, required"`
	Username string `env:"POSTGRESQL_USERNAME, required"`
	Password string `env:"POSTGRESQL_PASSWORD, required"`
	Database string `env:"POSTGRESQL_DATABASE, required"`
	Timezone string `env:"POSTGRESQL_TIMEZONE, required"`
	Schema   string `env:"POSTGRESQL_SCHEMA, required"`
	LogSql   bool   `env:"POSTGRESQL_LOG_SQL, required"`
}

Config is the configuration for the database.

type Store

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

func New

func New(cfg Config) (*Store, error)

func (*Store) ConsumeRefreshToken

func (s *Store) ConsumeRefreshToken(ctx context.Context, tokenID uuid.UUID, consumedAt time.Time) error

func (*Store) CreateAuthProvider

func (s *Store) CreateAuthProvider(ctx context.Context, provider domain.AuthProvider) (domain.AuthProvider, error)

func (*Store) CreateRefreshToken

func (s *Store) CreateRefreshToken(ctx context.Context, token domain.RefreshToken) error

func (*Store) CreateSession

func (s *Store) CreateSession(ctx context.Context, session domain.Session) (domain.Session, error)

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, user domain.User) (domain.User, error)

func (*Store) CurrentSchemaVersion

func (s *Store) CurrentSchemaVersion(ctx context.Context) (int, error)

func (*Store) DB

func (s *Store) DB() *gorm.DB

func (*Store) DeleteExpiredRefreshTokens

func (s *Store) DeleteExpiredRefreshTokens(ctx context.Context, now time.Time) error

func (*Store) DeleteExpiredSessions

func (s *Store) DeleteExpiredSessions(ctx context.Context, now time.Time) error

func (*Store) DeleteRefreshTokensBySession

func (s *Store) DeleteRefreshTokensBySession(ctx context.Context, sessionID uuid.UUID) error

func (*Store) DeleteUser

func (s *Store) DeleteUser(ctx context.Context, userID uuid.UUID) error

func (*Store) DisableUser

func (s *Store) DisableUser(ctx context.Context, userID uuid.UUID, disabledAt time.Time) error

func (*Store) GetAuthProviderByMethodAndUserID

func (s *Store) GetAuthProviderByMethodAndUserID(ctx context.Context, provider domain.Provider, userID uuid.UUID) (domain.AuthProvider, error)

func (*Store) GetAuthProviderByProviderAndProviderUserID

func (s *Store) GetAuthProviderByProviderAndProviderUserID(ctx context.Context, provider domain.Provider, providerUserID string) (domain.AuthProvider, error)

func (*Store) GetRefreshTokenByHash

func (s *Store) GetRefreshTokenByHash(ctx context.Context, hash string) (domain.RefreshToken, error)

func (*Store) GetSessionByID

func (s *Store) GetSessionByID(ctx context.Context, sessionID uuid.UUID) (domain.Session, error)

func (*Store) GetUserByEmail

func (s *Store) GetUserByEmail(ctx context.Context, email string) (domain.User, error)

func (*Store) GetUserByID

func (s *Store) GetUserByID(ctx context.Context, userID uuid.UUID) (domain.User, error)

func (*Store) IsUserAdmin

func (s *Store) IsUserAdmin(ctx context.Context, userID uuid.UUID) (bool, error)

func (*Store) IsUserDisabled

func (s *Store) IsUserDisabled(ctx context.Context, userID uuid.UUID) (bool, error)

func (*Store) Ping

func (s *Store) Ping(ctx context.Context) error

func (*Store) RevokeAllSessionsForUser

func (s *Store) RevokeAllSessionsForUser(ctx context.Context, userID uuid.UUID, revokedAt time.Time) error

func (*Store) RevokeSession

func (s *Store) RevokeSession(ctx context.Context, sessionID uuid.UUID, revokedAt time.Time) error

func (*Store) UpdateUsername

func (s *Store) UpdateUsername(ctx context.Context, userID uuid.UUID, username string) error

func (*Store) UserExistsByEmail

func (s *Store) UserExistsByEmail(ctx context.Context, email string) (bool, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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