Documentation
¶
Index ¶
- Variables
- func Exec(ctx context.Context, pool *pgxpool.Pool, sql string, args ...any) (pgconn.CommandTag, error)
- func GenerateRandomSecret(length int) (string, error)
- func HashToken(token string) string
- func QueryMany[T any](ctx context.Context, pool *pgxpool.Pool, sql string, args ...any) ([]T, error)
- func QueryOne[T any](ctx context.Context, pool *pgxpool.Pool, sql string, args ...any) (T, error)
- func WithTransaction(ctx context.Context, pool *pgxpool.Pool, fn func(pgx.Tx) error) error
- type Entity
- type Session
- type Store
- type User
- type UserAuthToken
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrObjectNotFound = errors.New("db.err.object_not_found")
View Source
var ErrTooManyRows = errors.New("db.err.too_many_rows")
Functions ¶
func GenerateRandomSecret ¶
Types ¶
type Store ¶
type Store interface {
UserByEmail(ctx context.Context, email string) (*User, error)
User(ctx context.Context, id uuid.UUID) (*User, error)
CreateUser(ctx context.Context, user *User) (*User, error)
CreateToken(ctx context.Context, userAuthToken *UserAuthToken) (*UserAuthToken, error)
Token(ctx context.Context, tokenHash string) (*UserAuthToken, error)
CompleteMagicLinkSignIn(ctx context.Context, userID uuid.UUID, tokenID uuid.UUID, usedAt time.Time) error
CreateSession(ctx context.Context, session *Session) (*Session, error)
UserBySessionID(ctx context.Context, sessionID uuid.UUID) (*User, error)
Session(ctx context.Context, sessionID uuid.UUID) (*Session, error)
DeleteSession(ctx context.Context, sessionID uuid.UUID) error
}
type User ¶
type UserAuthToken ¶
type UserAuthToken struct {
Entity
UserID uuid.UUID `json:"user_id" db:"user_id"`
Token string `json:"token" db:"token"`
IpAddress string `json:"ip_address" db:"ip_address"`
UserAgent string `json:"user_agent" db:"user_agent"`
ValidUntil time.Time `json:"valid_until" db:"valid_until"`
UsedAt *time.Time `json:"used_at" db:"used_at"`
}
func NewUserAuthToken ¶
Click to show internal directories.
Click to hide internal directories.