passwordreset

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Record

type Record struct {
	bun.BaseModel `bun:"table:password_reset"`

	ID            uuid.UUID  `bun:"id,pk,type:uuid"`
	UserID        uuid.UUID  `bun:"user_id,notnull,type:uuid"`
	Email         string     `bun:"email,notnull"`
	Status        string     `bun:"status,notnull"`
	JTI           string     `bun:"jti"`
	IssuedAt      *time.Time `bun:"issued_at,nullzero"`
	ExpiresAt     *time.Time `bun:"expires_at,nullzero"`
	UsedAt        *time.Time `bun:"used_at,nullzero"`
	ResetedAt     *time.Time `bun:"reseted_at,nullzero"`
	ScopeTenantID uuid.UUID  `bun:"scope_tenant_id,type:uuid,nullzero"`
	ScopeOrgID    uuid.UUID  `bun:"scope_org_id,type:uuid,nullzero"`
	CreatedAt     *time.Time `bun:"created_at,nullzero"`
	DeletedAt     *time.Time `bun:"deleted_at,soft_delete,nullzero"`
	UpdatedAt     *time.Time `bun:"updated_at,nullzero"`
}

Record models the persisted password_reset row.

type Repository

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

Repository implements types.PasswordResetRepository using Bun.

func NewRepository

func NewRepository(cfg RepositoryConfig) (*Repository, error)

NewRepository constructs the default password reset repository.

func (*Repository) ConsumeReset

func (r *Repository) ConsumeReset(ctx context.Context, jti string, usedAt time.Time) error

ConsumeReset marks the reset token as used, enforcing single-use semantics.

func (*Repository) CreateReset

CreateReset persists a password reset record.

func (*Repository) GetResetByJTI

func (r *Repository) GetResetByJTI(ctx context.Context, jti string) (*types.PasswordResetRecord, error)

GetResetByJTI returns the password reset record for a JTI.

func (*Repository) UpdateResetStatus

func (r *Repository) UpdateResetStatus(ctx context.Context, jti string, status types.PasswordResetStatus, usedAt time.Time) error

UpdateResetStatus updates reset status and usage timestamp.

type RepositoryConfig

type RepositoryConfig struct {
	DB         *bun.DB
	Repository repository.Repository[*Record]
	Clock      types.Clock
}

RepositoryConfig wires the Bun-backed password reset repository.

Jump to

Keyboard shortcuts

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