Documentation ¶
Index ¶
- Constants
- Variables
- func Migrate(db *sql.DB, dir string) error
- func MigrateFS(db *sql.DB, migrationsFS fs.FS, dir string) error
- func Open(cfg PostgresConfig) (*sql.DB, error)
- type Email
- type EmailService
- type Gallery
- type GalleryService
- func (srv *GalleryService) ByID(id int) (*Gallery, error)
- func (srv *GalleryService) ByUserID(userID int) ([]Gallery, error)
- func (srv *GalleryService) Create(title string, userID int) (*Gallery, error)
- func (srv *GalleryService) Delete(id int) error
- func (srv *GalleryService) Update(gallery *Gallery) error
- type PasswordReset
- type PasswordResetService
- type PostgresConfig
- type SMTPConfig
- type Session
- type SessionService
- type User
- type UserService
Constants ¶
View Source
const (
DefaultResetDuration = 1 * time.Hour
)
View Source
const (
DefaultSender = "support@lenslocked.com"
)
View Source
const (
// The minimum bytes per session token.
MinBytesPerToken = 32
)
Variables ¶
Functions ¶
Types ¶
type EmailService ¶
type EmailService struct { // DefaultSender is used as the default sender when one isn't provided for an // email. This is also used in functions where the email is a predetermined, // like the forgotten password email. DefaultSender string // contains filtered or unexported fields }
func NewEmailService ¶
func NewEmailService(config SMTPConfig) *EmailService
func (*EmailService) ForgotPassword ¶
func (es *EmailService) ForgotPassword(to, resetURL string) error
func (*EmailService) Send ¶
func (es *EmailService) Send(email Email) error
type GalleryService ¶
func (*GalleryService) ByUserID ¶
func (srv *GalleryService) ByUserID(userID int) ([]Gallery, error)
func (*GalleryService) Create ¶
func (srv *GalleryService) Create(title string, userID int) (*Gallery, error)
func (*GalleryService) Delete ¶
func (srv *GalleryService) Delete(id int) error
func (*GalleryService) Update ¶
func (srv *GalleryService) Update(gallery *Gallery) error
type PasswordReset ¶
type PasswordResetService ¶
type PasswordResetService struct { DB *sql.DB // BytesPerToken is used to determin how many bytes to use when generating each // PasswordReset token. If this value is not set or is less than the MinBytesPerToken // const it will be ignored and MinBytesPerToken will be used. BytesPerToken int // Duration is the amount of time that a PasswordReset token is valid for. // Defaults to DefaultResetDuration Duration time.Duration }
func (*PasswordResetService) Consume ¶
func (service *PasswordResetService) Consume(token string) (*User, error)
func (*PasswordResetService) Create ¶
func (service *PasswordResetService) Create(email string) (*PasswordReset, error)
type PostgresConfig ¶
type PostgresConfig struct { Host string Port string User string Password string Database string SSLMode string }
func DefaultPostgresConfig ¶
func DefaultPostgresConfig() PostgresConfig
func (PostgresConfig) String ¶
func (cfg PostgresConfig) String() string
type SessionService ¶
type SessionService struct { DB *sql.DB // BytesPerToken is used to determine how many bytes to use when generating // each session token. If this value is not set or is less than the MinBytesPerToken // const it will be ignored and MinBytesPerToken will be used. BytesPerToken int }
func (*SessionService) Delete ¶
func (ss *SessionService) Delete(token string) error
type UserService ¶
func (*UserService) Authenticate ¶
func (us *UserService) Authenticate(email, password string) (*User, error)
func (*UserService) UpdatePassword ¶
func (us *UserService) UpdatePassword(userID int, password string) error
Click to show internal directories.
Click to hide internal directories.