Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var OTPTemplate = Template{ ID: "otp", Email: func(data TemplateData) (EmailTemplateData, error) { otpData, ok := data.(*OTPTemplateData) if !ok { return EmailTemplateData{}, fmt.Errorf("invalid template data type") } return EmailTemplateData{ Name: otpData.Name, Subject: "Your verification code", Actions: []hermes.Action{ { Instructions: "Please use the following code to verify your account:", InviteCode: otpData.OTP, }, }, Outros: []string{ "If you did not request this code, please ignore this email.", }, }, nil }, SMS: func(data TemplateData) (SMSTemplateData, error) { otpData, ok := data.(*OTPTemplateData) if !ok { return SMSTemplateData{}, fmt.Errorf("invalid template data type") } return SMSTemplateData{ Message: fmt.Sprintf("Your verification code is: %s. Don't share this code with anyone.", otpData.OTP), }, nil }, }
View Source
var ResetPasswordTemplate = Template{ ID: "reset_password", Email: func(data TemplateData) (EmailTemplateData, error) { resetData, ok := data.(*ResetPasswordTemplateData) if !ok { return EmailTemplateData{}, fmt.Errorf("invalid template data type") } return EmailTemplateData{ Subject: "Reset Your Password", Name: resetData.Name, Actions: []hermes.Action{ { Instructions: "Click the button below to reset your password:", Button: hermes.Button{ Text: "Reset Password", Link: fmt.Sprintf("%s/reset-password/verify?code=%s&email=%s", config.GetURL(), resetData.ResetCode, resetData.Email), }, }, }, Outros: []string{ "If you did not request a password reset, please ignore this email.", }, }, nil }, SMS: func(data TemplateData) (SMSTemplateData, error) { return SMSTemplateData{}, fmt.Errorf("sms notifications not supported for password reset") }, }
View Source
var Templates = map[string]Template{ "otp": OTPTemplate, "reset_password": ResetPasswordTemplate, }
Functions ¶
This section is empty.
Types ¶
type EmailTemplateData ¶
type OTPTemplateData ¶
OTPTemplateData is a specific template data type for OTP notifications
func (*OTPTemplateData) Validate ¶
func (d *OTPTemplateData) Validate() error
Validate implements TemplateData interface for OTPTemplateData
type ResetPasswordTemplateData ¶
ResetPasswordTemplateData is a specific template data type for password reset notifications
func (*ResetPasswordTemplateData) Validate ¶
func (d *ResetPasswordTemplateData) Validate() error
Validate implements TemplateData interface for ResetPasswordTemplateData
type SMSTemplateData ¶
type SMSTemplateData struct {
Message string
}
type Template ¶
type Template struct {
ID string
Email func(data TemplateData) (EmailTemplateData, error)
SMS func(data TemplateData) (SMSTemplateData, error)
}
Template defines content for each supported channel
type TemplateData ¶
type TemplateData interface {
Validate() error
}
TemplateData is the interface that all template data must implement
Click to show internal directories.
Click to hide internal directories.