Documentation
¶
Index ¶
- type Config
- type ErrorResponse
- type Handler
- type Plugin
- func (p *Plugin) ID() string
- func (p *Plugin) Init(authInst core.Authsome) error
- func (p *Plugin) Migrate() error
- func (p *Plugin) RegisterHooks(_ *hooks.HookRegistry) error
- func (p *Plugin) RegisterRoutes(router forge.Router) error
- func (p *Plugin) RegisterServiceDecorators(_ *registry.ServiceRegistry) error
- type PluginOption
- type SendRequest
- type SendResponse
- type Service
- type VerifyRequest
- type VerifyResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// OTPLength is the length of the OTP code
OTPLength int `json:"otpLength"`
// ExpiryMinutes is the OTP expiry time in minutes
ExpiryMinutes int `json:"expiryMinutes"`
// MaxAttempts is the maximum verification attempts
MaxAttempts int `json:"maxAttempts"`
// RateLimitPerHour is the max OTP requests per hour
RateLimitPerHour int `json:"rateLimitPerHour"`
// AllowImplicitSignup allows creating users if they don't exist
AllowImplicitSignup bool `json:"allowImplicitSignup"`
// DevExposeOTP exposes the OTP in dev mode (for testing)
DevExposeOTP bool `json:"devExposeOTP"`
}
Config holds the email OTP plugin configuration
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default email OTP plugin configuration
type ErrorResponse ¶
type ErrorResponse = responses.ErrorResponse
Response types - use shared responses from core
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin implements the plugins.Plugin interface for Email OTP
func NewPlugin ¶
func NewPlugin(opts ...PluginOption) *Plugin
NewPlugin creates a new email OTP plugin instance with optional configuration
func (*Plugin) RegisterHooks ¶
func (p *Plugin) RegisterHooks(_ *hooks.HookRegistry) error
func (*Plugin) RegisterServiceDecorators ¶
func (p *Plugin) RegisterServiceDecorators(_ *registry.ServiceRegistry) error
type PluginOption ¶
type PluginOption func(*Plugin)
PluginOption is a functional option for configuring the email OTP plugin
func WithAllowImplicitSignup ¶
func WithAllowImplicitSignup(allow bool) PluginOption
WithAllowImplicitSignup sets whether implicit signup is allowed
func WithDefaultConfig ¶
func WithDefaultConfig(cfg Config) PluginOption
WithDefaultConfig sets the default configuration for the plugin
func WithExpiryMinutes ¶
func WithExpiryMinutes(minutes int) PluginOption
WithExpiryMinutes sets the OTP expiry time
func WithMaxAttempts ¶
func WithMaxAttempts(max int) PluginOption
WithMaxAttempts sets the maximum verification attempts
func WithOTPLength ¶
func WithOTPLength(length int) PluginOption
WithOTPLength sets the OTP code length
func WithRateLimitPerHour ¶
func WithRateLimitPerHour(limit int) PluginOption
WithRateLimitPerHour sets the rate limit per hour
type SendRequest ¶
type SendRequest struct {
Email string `json:"email" validate:"required,email" example:"user@example.com"`
}
Request types
type SendResponse ¶
type SendResponse struct {
Status string `json:"status" example:"sent"`
DevOTP string `json:"dev_otp,omitempty" example:"123456"`
}
Plugin-specific response
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements email OTP flow
func NewService ¶
func NewService( r *repo.EmailOTPRepository, userSvc user.ServiceInterface, sessionSvc session.ServiceInterface, auditSvc *audit.Service, notifAdapter *notificationPlugin.Adapter, cfg Config, logger forge.Logger, ) *Service
type VerifyRequest ¶
type VerifyResponse ¶
type VerifyResponse = responses.VerifyResponse