Versions in this module Expand all Collapse all v1 v1.1.0 Jun 26, 2026 v1.0.0 Apr 29, 2026 Changes in this version + var ErrNotFound = errors.New("not found") + var ErrOAuthLinkExists = errors.New("oauth link already exists for this provider") + var ErrUserExists = errors.New("user already exists") + type EmailUnsubscribe struct + Email string + ID string + func NewEmailUnsubscribe(email string) EmailUnsubscribe + type EmailVerification struct + CodeHash sql.NullString + DateCreated time.Time + ID string + MessageID sql.NullString + UnsubscribeToken sql.NullString + UserID string + func NewEmailVerification(userID, codeHash, unsubscribeToken string, createdAt time.Time) EmailVerification + func (ev *EmailVerification) IsExpired() bool + type RefreshToken struct + DateCreated time.Time + ExpiresAt time.Time + ID string + TokenHash string + UserID string + func NewRefreshToken(userID, tokenHash string, expiresAt time.Time) RefreshToken + func (rt *RefreshToken) IsExpired() bool + type User struct + DateCreated time.Time + DateUpdated sql.NullTime + DisplayName string + Email sql.NullString + EmailVerified bool + ID string + PasswordHash []byte + Role model.Role + Username string + func NewUser(username, name string, passwordHash []byte, role model.Role) User + func (u *User) IsEmpty() bool + func (u *User) SetEmail(email string, verified bool) + type UserOAuthLink struct + OAuthID string + OAuthProvider string + UserID string + func NewUserOAuthLink(userID, provider, oauthID string) UserOAuthLink + type UserRepo struct + func NewUserRepo(db *sqlx.DB, log *zap.Logger) *UserRepo + func (r *UserRepo) CheckUserExists(ctx context.Context, name string, role model.Role) (bool, error) + func (r *UserRepo) CreateEmailUnsubscribe(ctx context.Context, unsubscribe EmailUnsubscribe) error + func (r *UserRepo) CreateEmailVerification(ctx context.Context, vrf EmailVerification) error + func (r *UserRepo) CreateRefreshToken(ctx context.Context, refreshToken RefreshToken) error + func (r *UserRepo) CreateUser(ctx context.Context, user User) error + func (r *UserRepo) CreateUserOAuthLink(ctx context.Context, link UserOAuthLink) error + func (r *UserRepo) DeleteExpiredRefreshTokens(ctx context.Context) error + func (r *UserRepo) DeleteRefreshToken(ctx context.Context, tokenHash string) error + func (r *UserRepo) DeleteRefreshTokensByUserID(ctx context.Context, userID string) error + func (r *UserRepo) DeleteUser(ctx context.Context, userID string) error + func (r *UserRepo) GetEmailVerificationByUserID(ctx context.Context, userID string) (EmailVerification, error) + func (r *UserRepo) GetRefreshTokenByHash(ctx context.Context, tokenHash string) (RefreshToken, error) + func (r *UserRepo) GetUserByEmail(ctx context.Context, email string) (User, error) + func (r *UserRepo) GetUserByID(ctx context.Context, userID string) (user User, err error) + func (r *UserRepo) GetUserByOAuthLink(ctx context.Context, provider string, oauthID string) (User, error) + func (r *UserRepo) GetUserByUsername(ctx context.Context, username string) (user User, err error) + func (r *UserRepo) HasOAuthLink(ctx context.Context, userID string) (bool, error) + func (r *UserRepo) IsEmailUnsubscribed(ctx context.Context, email string) (bool, error) + func (r *UserRepo) RunWithTx(ctx context.Context, f func(context.Context) error) error + func (r *UserRepo) SetEmailVerificationMessageID(ctx context.Context, id string, messageID string) error + func (r *UserRepo) SetEmailVerificationUsed(ctx context.Context, id string, verified bool) error + func (r *UserRepo) SetUnsubscribeToken(ctx context.Context, id string, token string) error + func (r *UserRepo) SetUserEmailVerified(ctx context.Context, userID string) error + func (r *UserRepo) UpdateUser(ctx context.Context, user User) error