emailotp

package
v0.0.0-...-5538d7f Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FxMigrations = fx.Invoke(
	RunMigrations,
)

Functions

func NewLogin

func NewLogin(ro *Router) chttp.RouteResult

func NewSignup

func NewSignup(ro *Router) chttp.RouteResult

func RunMigrations

func RunMigrations(db *gorm.DB) error

Types

type Config

type Config struct {
	RequiresVerification bool
	VerificationEmail    EmailConfig
}

func GetDefaultConfig

func GetDefaultConfig() Config

type Credentials

type Credentials struct {
	ID        uint      `gorm:"primaryKey"`
	CreatedAt time.Time `gorm:"not null"`
	UpdatedAt time.Time `gorm:"not null"`

	UserUUID         string `gorm:"not null;uniqueIndex"`
	Email            string `gorm:"not null;uniqueIndex"`
	Verified         bool   `gorm:"not null;default:false"`
	VerificationCode uint   `gorm:"not null"`
}

func (Credentials) TableName

func (Credentials) TableName() string

type EmailConfig

type EmailConfig struct {
	From         string
	Subject      string
	BodyTemplate string
}

type Module

type Module struct {
	Svc    Svc
	Routes []chttp.Route
}

func NewModule

func NewModule(p NewModuleParams) (*Module, error)

type NewModuleParams

type NewModuleParams struct {
	Auth   cauth.Svc
	Mailer cmailer.Mailer
	Logger clogger.Logger
	Config Config

	DB *gorm.DB
}

type Repo

type Repo interface {
	GetCredentialsByEmail(ctx context.Context, email string) (*Credentials, error)
	AddCredentials(ctx context.Context, c *Credentials) error
}

func NewSQLRepo

func NewSQLRepo(db *gorm.DB) Repo

type Router

type Router struct {
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter(p RouterParams) *Router

func (*Router) HandleLogin

func (ro *Router) HandleLogin(w http.ResponseWriter, r *http.Request)

func (*Router) HandleSignup

func (ro *Router) HandleSignup(w http.ResponseWriter, r *http.Request)

func (*Router) Routes

func (ro *Router) Routes() []chttp.Route

type RouterParams

type RouterParams struct {
	fx.In

	RW     chttp.ReaderWriter
	Logger clogger.Logger

	Auth Svc
}

type Svc

type Svc interface {
	Signup(ctx context.Context, email string) (c *Credentials, token *string, err error)
	Login(ctx context.Context, email string, verificationCode uint) (c *Credentials, token string, err error)
}

func NewSvc

func NewSvc(auth cauth.Svc, repo Repo, mailer cmailer.Mailer, config Config) (Svc, error)

Jump to

Keyboard shortcuts

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