Documentation
¶
Index ¶
- Variables
- type Config
- type Controller
- func (c *Controller) AuthMiddleware() gin.HandlerFunc
- func (c *Controller) GetInvoicePreimage(gCtx *gin.Context)
- func (c *Controller) LoginHandler(gCtx *gin.Context)
- func (c *Controller) LogoutHandler(gCtx *gin.Context)
- func (c *Controller) MeHandler(gCtx *gin.Context)
- func (c *Controller) RegisterAuthMiddleware(router *gin.Engine)
- func (c *Controller) RegisterProtectedRoutes(router *gin.Engine)
- func (c *Controller) RegisterPublicRoutes(router *gin.Engine)
- func (c *Controller) UpdateProfileHandler(gCtx *gin.Context)
- func (c *Controller) VerifyTokenHandler(gCtx *gin.Context)
- type InvoiceStatus
- type LoginRequest
- type Store
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUserNotFound represents the error when a user is not found. ErrUserNotFound = errors.New("user not found") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { TokenExpirationMinutes int `long:"token_expiration_minutes" description:"Token expiration duration in minutes"` SessionSecret string `long:"session_secret" description:"Session secret"` }
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns all default values for the Config struct.
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController(emailService *email.ResendService, invoiceProvider l402.InvoiceProvider, logger *slog.Logger, store Store, clock utils.Clock, cfg *Config) *Controller
func (*Controller) AuthMiddleware ¶
func (c *Controller) AuthMiddleware() gin.HandlerFunc
func (*Controller) GetInvoicePreimage ¶
func (c *Controller) GetInvoicePreimage(gCtx *gin.Context)
func (*Controller) LoginHandler ¶
func (c *Controller) LoginHandler(gCtx *gin.Context)
func (*Controller) LogoutHandler ¶
func (c *Controller) LogoutHandler(gCtx *gin.Context)
func (*Controller) MeHandler ¶
func (c *Controller) MeHandler(gCtx *gin.Context)
func (*Controller) RegisterAuthMiddleware ¶
func (c *Controller) RegisterAuthMiddleware(router *gin.Engine)
RegisterAuthMiddleware registers the authentication middleware.
func (*Controller) RegisterProtectedRoutes ¶
func (c *Controller) RegisterProtectedRoutes(router *gin.Engine)
RegisterProtectedRoutes registers the protected authentication routes.
func (*Controller) RegisterPublicRoutes ¶
func (c *Controller) RegisterPublicRoutes(router *gin.Engine)
RegisterPublicRoutes registers the public authentication routes.
func (*Controller) UpdateProfileHandler ¶
func (c *Controller) UpdateProfileHandler(gCtx *gin.Context)
func (*Controller) VerifyTokenHandler ¶
func (c *Controller) VerifyTokenHandler(gCtx *gin.Context)
VerifyTokenHandler verifies the user token sent with a magic link and sets the user session.
type InvoiceStatus ¶
type LoginRequest ¶
type LoginRequest struct {
Email string `json:"email" binding:"required,email"`
}
type Store ¶
type Store interface { GetUserByID(ctx context.Context, id int64) (User, error) GetOrCreateUserByEmail(ctx context.Context, email string) (int64, error) UpdateUserLightningAddress(ctx context.Context, id int64, lightningAddress string) error UpdateUserVerified(ctx context.Context, email string, verified bool) error StoreToken(ctx context.Context, email, token string, expiration time.Time) error VerifyToken(ctx context.Context, token string) (string, error) // GetInvoiceStatus retrieves the invoice status for a given payment hash. // Used to cache requests. GetInvoiceStatus(ctx context.Context, paymentHash string) (*InvoiceStatus, error) // UpsertInvoiceStatus upserts the invoice status for a given payment hash. // and returns the updated invoice status. UpsertInvoiceStatus(ctx context.Context, paymentHash, preimage string, settled bool) (*InvoiceStatus, error) }
Click to show internal directories.
Click to hide internal directories.