Documentation
¶
Index ¶
- Variables
- type CreateEmailVerificationTokenParams
- type CreateOIDCUserParams
- type CreateParams
- type CreatePasswordResetTokenParams
- type MFAChallenge
- type Repository
- type RepositoryWithLogging
- func (_d RepositoryWithLogging) ConsumeMFAChallenge(ctx context.Context, tx postgres.DBTX, id int) (err error)
- func (_d RepositoryWithLogging) CreateEmailVerificationToken(ctx context.Context, tx postgres.DBTX, ...) (err error)
- func (_d RepositoryWithLogging) CreateMFAChallenge(ctx context.Context, tx postgres.DBTX, userSlug slug.Slug, ...) (err error)
- func (_d RepositoryWithLogging) CreateOIDCUser(ctx context.Context, tx postgres.DBTX, params *CreateOIDCUserParams) (up1 *UserPublic, err error)
- func (_d RepositoryWithLogging) CreatePasswordResetToken(ctx context.Context, tx postgres.DBTX, params CreatePasswordResetTokenParams) (err error)
- func (_d RepositoryWithLogging) CreateUser(ctx context.Context, tx postgres.DBTX, user *CreateParams) (up1 *UserPublic, err error)
- func (_d RepositoryWithLogging) FindByEmail(ctx context.Context, tx postgres.DBTX, email string) (up1 *UserPublic, err error)
- func (_d RepositoryWithLogging) FindByEmailVerificationToken(ctx context.Context, tx postgres.DBTX, tokenHash string) (up1 *UserPublic, err error)
- func (_d RepositoryWithLogging) FindByEmailWithPassword(ctx context.Context, tx postgres.DBTX, email string) (up1 *UserWithPassword, err error)
- func (_d RepositoryWithLogging) FindByOIDCProvider(ctx context.Context, tx postgres.DBTX, provider string, providerID string) (up1 *UserPublic, err error)
- func (_d RepositoryWithLogging) FindByPasswordResetToken(ctx context.Context, tx postgres.DBTX, tokenHash string) (up1 *UserPublic, err error)
- func (_d RepositoryWithLogging) FindBySlug(ctx context.Context, tx postgres.DBTX, slug slug.Slug) (up1 *UserPublic, err error)
- func (_d RepositoryWithLogging) FindBySlugWithPassword(ctx context.Context, tx postgres.DBTX, slug slug.Slug) (up1 *UserWithPassword, err error)
- func (_d RepositoryWithLogging) FindMFAChallengeByToken(ctx context.Context, tx postgres.DBTX, challengeTokenHash string) (mp1 *MFAChallenge, err error)
- func (_d RepositoryWithLogging) IncrementMFAChallengeAttempts(ctx context.Context, tx postgres.DBTX, id int) (err error)
- func (_d RepositoryWithLogging) IsSlugReserved(ctx context.Context, tx postgres.DBTX, slug slug.Slug) (b1 bool, err error)
- func (_d RepositoryWithLogging) MarkEmailAsVerified(ctx context.Context, tx postgres.DBTX, slug slug.Slug, verifiedAt time.Time) (err error)
- func (_d RepositoryWithLogging) UpdatePassword(ctx context.Context, tx postgres.DBTX, slug slug.Slug, hashedPassword string) (err error)
- func (_d RepositoryWithLogging) UpdateProfile(ctx context.Context, tx postgres.DBTX, params *UpdateProfileParams) (err error)
- type UpdateProfileParams
- type UserPublic
- type UserWithPassword
Constants ¶
This section is empty.
Variables ¶
var ( ErrUserNotFound = xerror.NotFound(xerror.User) ErrEmailAlreadyExists = xerror.AlreadyExists(xerror.UserEmail) ErrSlugAlreadyExists = xerror.AlreadyExists(xerror.User) ErrMFAChallengeConsumed = xerror.InvalidToken().Detail( "mfa challenge already consumed", ) )
Functions ¶
This section is empty.
Types ¶
type CreateOIDCUserParams ¶
type CreateParams ¶
type MFAChallenge ¶
type Repository ¶
type Repository interface {
CreateUser(ctx context.Context, tx postgres.DBTX, user *CreateParams) (*UserPublic, error)
CreateOIDCUser(
ctx context.Context,
tx postgres.DBTX,
params *CreateOIDCUserParams,
) (*UserPublic, error)
FindBySlug(ctx context.Context, tx postgres.DBTX, slug slug.Slug) (*UserPublic, error)
IsSlugReserved(ctx context.Context, tx postgres.DBTX, slug slug.Slug) (bool, error)
FindByEmailWithPassword(
ctx context.Context,
tx postgres.DBTX,
email string,
) (*UserWithPassword, error)
FindBySlugWithPassword(
ctx context.Context,
tx postgres.DBTX,
slug slug.Slug,
) (*UserWithPassword, error)
FindByOIDCProvider(
ctx context.Context,
tx postgres.DBTX,
provider, providerID string,
) (*UserPublic, error)
FindByEmail(ctx context.Context, tx postgres.DBTX, email string) (*UserPublic, error)
CreateEmailVerificationToken(
ctx context.Context,
tx postgres.DBTX,
params CreateEmailVerificationTokenParams,
) error
CreatePasswordResetToken(
ctx context.Context,
tx postgres.DBTX,
params CreatePasswordResetTokenParams,
) error
CreateMFAChallenge(
ctx context.Context,
tx postgres.DBTX,
userSlug slug.Slug,
challengeTokenHash string,
codeHash string,
expiresAt time.Time,
) error
FindMFAChallengeByToken(
ctx context.Context,
tx postgres.DBTX,
challengeTokenHash string,
) (*MFAChallenge, error)
IncrementMFAChallengeAttempts(ctx context.Context, tx postgres.DBTX, id int) error
ConsumeMFAChallenge(ctx context.Context, tx postgres.DBTX, id int) error
FindByEmailVerificationToken(
ctx context.Context,
tx postgres.DBTX,
tokenHash string,
) (*UserPublic, error)
FindByPasswordResetToken(
ctx context.Context,
tx postgres.DBTX,
tokenHash string,
) (*UserPublic, error)
MarkEmailAsVerified(
ctx context.Context,
tx postgres.DBTX,
slug slug.Slug,
verifiedAt time.Time,
) error
UpdatePassword(
ctx context.Context,
tx postgres.DBTX,
slug slug.Slug,
hashedPassword string,
) error
UpdateProfile(ctx context.Context, tx postgres.DBTX, params *UpdateProfileParams) error
}
func NewRepository ¶
func NewRepository() Repository
func NewRepositoryWithLogging ¶
func NewRepositoryWithLogging(base Repository, logger *slog.Logger) Repository
NewRepositoryWithLogging wraps base with method completion logging.
type RepositoryWithLogging ¶
type RepositoryWithLogging struct {
// contains filtered or unexported fields
}
RepositoryWithLogging implements Repository with method completion logging.
func (RepositoryWithLogging) ConsumeMFAChallenge ¶
func (_d RepositoryWithLogging) ConsumeMFAChallenge(ctx context.Context, tx postgres.DBTX, id int) (err error)
ConsumeMFAChallenge implements Repository.
func (RepositoryWithLogging) CreateEmailVerificationToken ¶
func (_d RepositoryWithLogging) CreateEmailVerificationToken(ctx context.Context, tx postgres.DBTX, params CreateEmailVerificationTokenParams) (err error)
CreateEmailVerificationToken implements Repository.
func (RepositoryWithLogging) CreateMFAChallenge ¶
func (_d RepositoryWithLogging) CreateMFAChallenge(ctx context.Context, tx postgres.DBTX, userSlug slug.Slug, challengeTokenHash string, codeHash string, expiresAt time.Time) (err error)
CreateMFAChallenge implements Repository.
func (RepositoryWithLogging) CreateOIDCUser ¶
func (_d RepositoryWithLogging) CreateOIDCUser(ctx context.Context, tx postgres.DBTX, params *CreateOIDCUserParams) (up1 *UserPublic, err error)
CreateOIDCUser implements Repository.
func (RepositoryWithLogging) CreatePasswordResetToken ¶
func (_d RepositoryWithLogging) CreatePasswordResetToken(ctx context.Context, tx postgres.DBTX, params CreatePasswordResetTokenParams) (err error)
CreatePasswordResetToken implements Repository.
func (RepositoryWithLogging) CreateUser ¶
func (_d RepositoryWithLogging) CreateUser(ctx context.Context, tx postgres.DBTX, user *CreateParams) (up1 *UserPublic, err error)
CreateUser implements Repository.
func (RepositoryWithLogging) FindByEmail ¶
func (_d RepositoryWithLogging) FindByEmail(ctx context.Context, tx postgres.DBTX, email string) (up1 *UserPublic, err error)
FindByEmail implements Repository.
func (RepositoryWithLogging) FindByEmailVerificationToken ¶
func (_d RepositoryWithLogging) FindByEmailVerificationToken(ctx context.Context, tx postgres.DBTX, tokenHash string) (up1 *UserPublic, err error)
FindByEmailVerificationToken implements Repository.
func (RepositoryWithLogging) FindByEmailWithPassword ¶
func (_d RepositoryWithLogging) FindByEmailWithPassword(ctx context.Context, tx postgres.DBTX, email string) (up1 *UserWithPassword, err error)
FindByEmailWithPassword implements Repository.
func (RepositoryWithLogging) FindByOIDCProvider ¶
func (_d RepositoryWithLogging) FindByOIDCProvider(ctx context.Context, tx postgres.DBTX, provider string, providerID string) (up1 *UserPublic, err error)
FindByOIDCProvider implements Repository.
func (RepositoryWithLogging) FindByPasswordResetToken ¶
func (_d RepositoryWithLogging) FindByPasswordResetToken(ctx context.Context, tx postgres.DBTX, tokenHash string) (up1 *UserPublic, err error)
FindByPasswordResetToken implements Repository.
func (RepositoryWithLogging) FindBySlug ¶
func (_d RepositoryWithLogging) FindBySlug(ctx context.Context, tx postgres.DBTX, slug slug.Slug) (up1 *UserPublic, err error)
FindBySlug implements Repository.
func (RepositoryWithLogging) FindBySlugWithPassword ¶
func (_d RepositoryWithLogging) FindBySlugWithPassword(ctx context.Context, tx postgres.DBTX, slug slug.Slug) (up1 *UserWithPassword, err error)
FindBySlugWithPassword implements Repository.
func (RepositoryWithLogging) FindMFAChallengeByToken ¶
func (_d RepositoryWithLogging) FindMFAChallengeByToken(ctx context.Context, tx postgres.DBTX, challengeTokenHash string) (mp1 *MFAChallenge, err error)
FindMFAChallengeByToken implements Repository.
func (RepositoryWithLogging) IncrementMFAChallengeAttempts ¶
func (_d RepositoryWithLogging) IncrementMFAChallengeAttempts(ctx context.Context, tx postgres.DBTX, id int) (err error)
IncrementMFAChallengeAttempts implements Repository.
func (RepositoryWithLogging) IsSlugReserved ¶
func (_d RepositoryWithLogging) IsSlugReserved(ctx context.Context, tx postgres.DBTX, slug slug.Slug) (b1 bool, err error)
IsSlugReserved implements Repository.
func (RepositoryWithLogging) MarkEmailAsVerified ¶
func (_d RepositoryWithLogging) MarkEmailAsVerified(ctx context.Context, tx postgres.DBTX, slug slug.Slug, verifiedAt time.Time) (err error)
MarkEmailAsVerified implements Repository.
func (RepositoryWithLogging) UpdatePassword ¶
func (_d RepositoryWithLogging) UpdatePassword(ctx context.Context, tx postgres.DBTX, slug slug.Slug, hashedPassword string) (err error)
UpdatePassword implements Repository.
func (RepositoryWithLogging) UpdateProfile ¶
func (_d RepositoryWithLogging) UpdateProfile(ctx context.Context, tx postgres.DBTX, params *UpdateProfileParams) (err error)
UpdateProfile implements Repository.
type UpdateProfileParams ¶
type UserPublic ¶
type UserPublic struct {
AuthenticationVersion int64
Slug slug.Slug
Email string
FullName string
Role model.Role
Locale string
AvatarURL string
PhoneNumber string
JobTitle string
Timezone string
MFAEmailEnabled bool
HasLocalPassword bool
VerifiedAt time.Time
CreatedAt time.Time
UpdatedAt time.Time
}