Documentation
¶
Index ¶
- type Config
- type ErrorResponse
- type Handler
- type LinkRequest
- type LinkResponse
- 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 Service
- func (s *Service) GetUserByID(ctx context.Context, id xid.ID) (*coreuser.User, error)
- func (s *Service) LinkGuest(ctx context.Context, token, email, password, name string) (*coreuser.User, error)
- func (s *Service) SignInGuest(ctx context.Context, appID, envID xid.ID, orgID *xid.ID, ip, ua string) (*session.Session, error)
- type SignInRequest
- type SignInResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// EnableAnonymous enables anonymous user creation
EnableAnonymous bool `json:"enableAnonymous"`
// SessionExpiryHours is the anonymous session expiry time in hours
SessionExpiryHours int `json:"sessionExpiryHours"`
// CleanupIntervalHours is how often to clean up expired anonymous users
CleanupIntervalHours int `json:"cleanupIntervalHours"`
// AutoConvert allows converting anonymous users to registered users
AutoConvert bool `json:"autoConvert"`
}
Config holds the anonymous plugin configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default anonymous plugin configuration.
type ErrorResponse ¶
type ErrorResponse = responses.ErrorResponse
ErrorResponse is the error response type.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
type LinkRequest ¶
type LinkResponse ¶
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
func NewPlugin ¶
func NewPlugin(opts ...PluginOption) *Plugin
NewPlugin creates a new anonymous plugin instance with optional configuration.
func (*Plugin) RegisterHooks ¶
func (p *Plugin) RegisterHooks(_ *hooks.HookRegistry) error
func (*Plugin) RegisterRoutes ¶
RegisterRoutes registers Anonymous plugin routes.
func (*Plugin) RegisterServiceDecorators ¶
func (p *Plugin) RegisterServiceDecorators(_ *registry.ServiceRegistry) error
type PluginOption ¶
type PluginOption func(*Plugin)
PluginOption is a functional option for configuring the anonymous plugin.
func WithAutoConvert ¶
func WithAutoConvert(enable bool) PluginOption
WithAutoConvert sets whether auto-conversion is enabled.
func WithCleanupIntervalHours ¶
func WithCleanupIntervalHours(hours int) PluginOption
WithCleanupIntervalHours sets the cleanup interval.
func WithDefaultConfig ¶
func WithDefaultConfig(cfg Config) PluginOption
WithDefaultConfig sets the default configuration for the plugin.
func WithEnableAnonymous ¶
func WithEnableAnonymous(enable bool) PluginOption
WithEnableAnonymous sets whether anonymous users are enabled.
func WithSessionExpiryHours ¶
func WithSessionExpiryHours(hours int) PluginOption
WithSessionExpiryHours sets the session expiry time.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides anonymous sign-in by creating a guest user and session.
func NewService ¶
func (*Service) GetUserByID ¶
GetUserByID is a helper to get a user by ID (returns DTO).
type SignInRequest ¶
type SignInRequest struct {
}
SignInRequest is the request type for anonymous sign-in.
type SignInResponse ¶
type SignInResponse struct {
Token string `example:"session_token_abc123" json:"token"`
Session any `json:"session"`
User any `json:"user"`
}
SignInResponse is the response type for anonymous sign-in.