types

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package types defines the domain models and request/response types used by the emailotp plugin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LoginWithEmailRequest

type LoginWithEmailRequest struct {
	Email    string `json:"email"`    // User email address
	Password string `json:"password"` // User password
}

LoginWithEmailRequest is the request body for the email+password login endpoint. Authenticates an existing user using their registered email address and password.

type RegisterWithEmailRequest

type RegisterWithEmailRequest struct {
	Avatar   *string `json:"avatar"`   // Optional avatar URL
	Name     *string `json:"name"`     // User display name (required)
	Email    string  `json:"email"`    // User email address (required)
	Password string  `json:"password"` // User password (required)
}

RegisterWithEmailRequest is the request body for the email+password registration endpoint. Creates a new user account. Callers should trigger an email verification OTP (via SendOTPRequest with Purpose "email_verification") after a successful response.

type SendOTPRequest

type SendOTPRequest struct {
	Email   string `json:"email"`   // Email address to send OTP to
	UserID  string `json:"userId"`  // Aegis user ID requesting the OTP
	Purpose string `json:"purpose"` // OTP purpose ("email_verification", "password_reset", "login_mfa")
}

SendOTPRequest is the request body for the OTP dispatch endpoint. Triggers a one-time passcode to be sent to the given email address. Purpose controls which flow the OTP belongs to:

  • "email_verification" — confirm a newly registered email address
  • "password_reset" — initiate a password reset flow
  • "login_mfa" — second-factor login challenge

type Store

type Store interface {
	// CreateUser creates a new user with an email address.
	//
	// The email is initially unverified (emailVerified: false).
	CreateUser(ctx context.Context, user User) (*User, error)

	// GetUserByEmail retrieves a user by email address.
	GetUserByEmail(ctx context.Context, email string) (*User, error)

	// UpdateUserEmail updates a user's email address and verification status.
	UpdateUserEmail(ctx context.Context, userID, email string, verified bool) error
}

Store defines the interface for Email OTP verification storage operations.

This interface provides email-specific user management operations:

  • User creation with email addresses
  • Email lookup for authentication
  • Email verification status updates

Thread Safety: Implementations must be safe for concurrent use.

type User

type User struct {
	auth.User
	EmailVerified bool `json:"emailVerified"` // Whether the user's email address has been verified
}

User extends the core auth.User model with the email-specific verification flag. EmailVerified is false until the user completes an email verification flow (e.g., by verifying an OTP sent to their address via SendOTPRequest).

type VerifyOTPRequest

type VerifyOTPRequest struct {
	Email   string `json:"email"`   // Email address to verify
	Code    string `json:"code"`    // OTP code to verify
	Purpose string `json:"purpose"` // OTP purpose
}

VerifyOTPRequest is the request body for the OTP verification endpoint. Submits a one-time passcode to confirm a given email address or complete a flow. Purpose must match the value used in the corresponding SendOTPRequest.

Jump to

Keyboard shortcuts

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