verification

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package verification defines the VerificationToken primitive: a secure, expiring, single-use token reusable by the core (email verification, password reset) and by plugins (magic link, OTP, one-time token, ...).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Purpose

type Purpose string

Purpose namespaces tokens so a token issued for one flow can never be consumed by another. Plugins should prefix their purposes ("magiclink:login").

const (
	PurposeEmailVerification Purpose = "email_verification"
	PurposePasswordReset     Purpose = "password_reset"
)

Core purposes.

type Token

type Token struct {
	ID        string     `json:"id"`
	Purpose   Purpose    `json:"purpose"`
	Subject   string     `json:"subject"`
	TokenHash string     `json:"token_hash"`
	ExpiresAt time.Time  `json:"expires_at"`
	UsedAt    *time.Time `json:"used_at,omitempty"`
	CreatedAt time.Time  `json:"created_at"`
}

Token is a single-use verification token. Only TokenHash is persisted.

func (*Token) Expired

func (t *Token) Expired(now time.Time) bool

Expired reports whether the token is expired at the given instant.

func (*Token) Used

func (t *Token) Used() bool

Used reports whether the token has already been consumed.

Jump to

Keyboard shortcuts

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