2016-08-19 00:45:39 +00:00
|
|
|
package kolide
|
2016-08-12 19:20:29 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2016-09-15 14:52:17 +00:00
|
|
|
// PasswordResetStore manages password resets in the Datastore
|
|
|
|
type PasswordResetStore interface {
|
|
|
|
NewPasswordResetRequest(req *PasswordResetRequest) (*PasswordResetRequest, error)
|
|
|
|
SavePasswordResetRequest(req *PasswordResetRequest) error
|
2016-08-19 00:45:39 +00:00
|
|
|
DeletePasswordResetRequest(req *PasswordResetRequest) error
|
2016-09-15 14:52:17 +00:00
|
|
|
DeletePasswordResetRequestsForUser(userID uint) error
|
2016-08-19 00:45:39 +00:00
|
|
|
FindPassswordResetByID(id uint) (*PasswordResetRequest, error)
|
2016-08-20 06:56:49 +00:00
|
|
|
FindPassswordResetsByUserID(id uint) ([]*PasswordResetRequest, error)
|
2016-08-19 00:45:39 +00:00
|
|
|
FindPassswordResetByToken(token string) (*PasswordResetRequest, error)
|
|
|
|
FindPassswordResetByTokenAndUserID(token string, id uint) (*PasswordResetRequest, error)
|
|
|
|
}
|
|
|
|
|
2016-09-15 14:52:17 +00:00
|
|
|
// Mailer is an email campaign
|
|
|
|
// Types which implement the Campaign interface
|
|
|
|
// can be marshalled into an email body
|
|
|
|
type Mailer interface {
|
|
|
|
Message() ([]byte, error)
|
2016-08-12 19:20:29 +00:00
|
|
|
}
|
|
|
|
|
2016-09-15 14:52:17 +00:00
|
|
|
type Email struct {
|
2016-12-20 21:54:30 +00:00
|
|
|
Subject string
|
|
|
|
To []string
|
|
|
|
Config *AppConfig
|
|
|
|
Mailer Mailer
|
2016-08-12 19:20:29 +00:00
|
|
|
}
|
|
|
|
|
2016-09-15 14:52:17 +00:00
|
|
|
type MailService interface {
|
|
|
|
SendEmail(e Email) error
|
2016-08-12 19:20:29 +00:00
|
|
|
}
|
2016-08-19 00:45:39 +00:00
|
|
|
|
|
|
|
// PasswordResetRequest represents a database table for
|
|
|
|
// Password Reset Requests
|
|
|
|
type PasswordResetRequest struct {
|
2016-11-16 13:47:49 +00:00
|
|
|
UpdateCreateTimestamps
|
|
|
|
ID uint
|
|
|
|
ExpiresAt time.Time `db:"expires_at"`
|
|
|
|
UserID uint `db:"user_id"`
|
|
|
|
Token string
|
2016-08-19 00:45:39 +00:00
|
|
|
}
|