passcodestore

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const ResetTTL = 24 * time.Hour

ResetTTL is how long a pending reset request stays valid.

Variables

View Source
var ErrNotFound = errors.New("reset request not found")

ErrNotFound is returned when a reset request does not exist or has expired.

Functions

This section is empty.

Types

type InMemory

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

InMemory is an in-process Store. Entries are dropped lazily on read once expired.

func NewInMemory

func NewInMemory() *InMemory

NewInMemory returns an empty in-memory store.

func (*InMemory) Approve

func (s *InMemory) Approve(uid, requestID string) (messages.PasscodeReset, error)

Approve flips the request to approved if it belongs to uid and is not expired.

func (*InMemory) Create

func (s *InMemory) Create(uid string, req messages.PasscodeReset) error

Create inserts (or replaces) a reset request for uid keyed by req.RequestID.

func (*InMemory) Delete

func (s *InMemory) Delete(uid, requestID string) error

Delete removes a pending request if it belongs to uid.

func (*InMemory) Get

func (s *InMemory) Get(requestID string) (OwnedReset, error)

Get returns the reset request for requestID, dropping it if it has expired.

func (*InMemory) ListForUser

func (s *InMemory) ListForUser(uid string) []messages.PasscodeReset

ListForUser returns all non-expired pending (unapproved) requests for uid.

type OwnedReset

type OwnedReset struct {
	UID string
	messages.PasscodeReset
}

OwnedReset pairs a reset request with the user that owns it.

type Store

type Store interface {
	Create(uid string, req messages.PasscodeReset) error
	Get(requestID string) (OwnedReset, error)
	ListForUser(uid string) []messages.PasscodeReset
	Approve(uid, requestID string) (messages.PasscodeReset, error)
	Delete(uid, requestID string) error
}

Store persists pending passcode reset requests.

Jump to

Keyboard shortcuts

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