store

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 16 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")
	ErrorChallengeNotFound            = errors.New("challenge not found")
	ErrorVerificationCodeNotFound     = errors.New("verification code not found")
	ErrorEmailJobNotFound             = errors.New("email job not found")
	ErrorPendingSignupActionNotFound  = errors.New("pending signup action not found")
	ErrorPendingPasswordResetNotFound = errors.New("pending password reset not found")
	ErrorRoleNotFound                 = errors.New("role 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
	Port     int
	Username string
	Password string
	Database string
	Timezone string
	Schema   string
	LogSql   bool

	MaxOpenConns    int
	MaxIdleConns    int
	ConnMaxLifetime time.Duration
	ConnMaxIdleTime time.Duration
}

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) AddUserPlatformRoleByName added in v0.1.13

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

func (*Store) ClaimNextEmailJob added in v0.1.12

func (s *Store) ClaimNextEmailJob(ctx context.Context, now time.Time) (domain.EmailJob, error)

func (*Store) ConsumeChallenge added in v0.1.12

func (s *Store) ConsumeChallenge(ctx context.Context, challengeID uuid.UUID, now time.Time) error

func (*Store) ConsumeRefreshToken

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

func (*Store) CreateAllowedEmail added in v0.1.10

func (s *Store) CreateAllowedEmail(ctx context.Context, allowedEmail domain.AllowedEmail) error

func (*Store) CreateAuthProvider

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

func (*Store) CreateChallenge added in v0.1.12

func (s *Store) CreateChallenge(ctx context.Context, in domain.Challenge) (domain.Challenge, error)

func (*Store) CreateEmailJob added in v0.1.12

func (s *Store) CreateEmailJob(ctx context.Context, in domain.EmailJob) (domain.EmailJob, error)

func (*Store) CreatePendingPasswordReset added in v0.1.14

func (s *Store) CreatePendingPasswordReset(ctx context.Context, in domain.PendingPasswordReset) (domain.PendingPasswordReset, error)

func (*Store) CreatePendingSignupAction added in v0.1.12

func (s *Store) CreatePendingSignupAction(ctx context.Context, in domain.PendingSignupAction) (domain.PendingSignupAction, 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) DeleteAllowedEmail added in v0.1.10

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

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) DeleteFailedEmailJobsBefore added in v0.1.12

func (s *Store) DeleteFailedEmailJobsBefore(ctx context.Context, t time.Time) error

func (*Store) DeletePendingPasswordResetByChallengeID added in v0.1.14

func (s *Store) DeletePendingPasswordResetByChallengeID(ctx context.Context, challengeID uuid.UUID) error

func (*Store) DeleteRefreshTokensBySession

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

func (*Store) DeleteSentEmailJobsBefore added in v0.1.12

func (s *Store) DeleteSentEmailJobsBefore(ctx context.Context, t time.Time) 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) GetChallengeByID added in v0.1.12

func (s *Store) GetChallengeByID(ctx context.Context, challengeID uuid.UUID) (domain.Challenge, error)

func (*Store) GetPendingPasswordResetByChallengeID added in v0.1.14

func (s *Store) GetPendingPasswordResetByChallengeID(ctx context.Context, challengeID uuid.UUID) (domain.PendingPasswordReset, error)

func (*Store) GetPendingSignupActionByChallengeID added in v0.1.12

func (s *Store) GetPendingSignupActionByChallengeID(ctx context.Context, challengeID uuid.UUID) (domain.PendingSignupAction, 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) GetUserPlatformRoleNames added in v0.1.13

func (s *Store) GetUserPlatformRoleNames(ctx context.Context, userID uuid.UUID) ([]string, error)

func (*Store) GetVerificationCodeByChallengeID added in v0.1.12

func (s *Store) GetVerificationCodeByChallengeID(ctx context.Context, challengeID uuid.UUID) (domain.VerificationCode, error)

func (*Store) IncrementChallengeAttemptCount added in v0.1.12

func (s *Store) IncrementChallengeAttemptCount(ctx context.Context, challengeID uuid.UUID) error

func (*Store) IncrementChallengeResendCount added in v0.1.12

func (s *Store) IncrementChallengeResendCount(ctx context.Context, challengeID uuid.UUID, now time.Time) (bool, error)

func (*Store) IsEmailAllowed added in v0.1.10

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

func (*Store) IsUserDisabled

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

func (*Store) ListAllowedEmails added in v0.1.13

func (s *Store) ListAllowedEmails(ctx context.Context) ([]domain.AllowedEmail, error)

func (*Store) MarkEmailJobFailed added in v0.1.12

func (s *Store) MarkEmailJobFailed(ctx context.Context, jobID uuid.UUID, lastError string) error

func (*Store) MarkEmailJobSent added in v0.1.12

func (s *Store) MarkEmailJobSent(ctx context.Context, jobID uuid.UUID, now time.Time) error

func (*Store) Ping

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

func (*Store) RemoveUserPlatformRoleByName added in v0.1.13

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

func (*Store) RequeueEmailJob added in v0.1.12

func (s *Store) RequeueEmailJob(ctx context.Context, jobID uuid.UUID, lastError string, nextAttemptAt time.Time) 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) SetChallengeLastSentAt added in v0.1.12

func (s *Store) SetChallengeLastSentAt(ctx context.Context, challengeID uuid.UUID, now time.Time) error

func (*Store) UpdatePasswordHash added in v0.1.14

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

func (*Store) UpdateUsername

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

func (*Store) UpsertVerificationCode added in v0.1.12

func (s *Store) UpsertVerificationCode(ctx context.Context, in domain.VerificationCode) 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