Documentation
¶
Index ¶
- func CleanupExpiredTokens(db *sql.DB) (int64, error)
- func GenerateResetToken(userID int64) (string, time.Time, error)
- func IsSMTPEnabled(db *sql.DB) bool
- func LoadTemplate(name string) (string, error)
- func MarkTokenUsed(db *sql.DB, token string) error
- func SaveResetToken(db *sql.DB, userID int64, token string, expiresAt time.Time) error
- func SendAdminNotification(ctx context.Context, adminEmail, userName, userEmail, companyName, lang string, ...) error
- func SendEmail(ctx context.Context, msg *mail.Msg, db *sql.DB) error
- func SendReport(ctx context.Context, to string, contracts []reports.Contract, db *sql.DB) error
- func SendVerificationCode(ctx context.Context, to, code, lang string, db *sql.DB) error
- func SendWithMailtrap(ctx context.Context, msg *mail.Msg, cfg SMTPConfig) error
- func ValidateResetToken(db *sql.DB, token string) (int64, error)
- type EmailTemplate
- func GetAdminNotificationTemplate(lang, userName, userEmail, companyName string) EmailTemplate
- func GetContractExpiryTemplate(...) EmailTemplate
- func GetPasswordResetTemplate(lang, resetLink, userName string) EmailTemplate
- func GetReportTemplate(reportDate string) EmailTemplate
- func GetVerificationTemplate(lang, code string) EmailTemplate
- type SMTPConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupExpiredTokens ¶ added in v0.45.0
CleanupExpiredTokens deletes expired and unused tokens from the database. Returns the number of tokens deleted.
func GenerateResetToken ¶ added in v0.45.0
GenerateResetToken generates a new random reset token for the given user ID. Returns the token string, expiration time, and any error.
func IsSMTPEnabled ¶ added in v0.38.0
IsSMTPEnabled checks if SMTP is enabled in settings
func LoadTemplate ¶ added in v0.45.0
func MarkTokenUsed ¶ added in v0.45.0
MarkTokenUsed marks a reset token as used by setting the used_at timestamp.
func SaveResetToken ¶ added in v0.45.0
SaveResetToken saves a password reset token to the database.
func SendAdminNotification ¶
func SendAdminNotification(ctx context.Context, adminEmail, userName, userEmail, companyName, lang string, db *sql.DB) error
SendAdminNotification sends a notification email to an admin
func SendReport ¶ added in v0.46.0
SendReport sends a contract report email with PDF attachment
func SendVerificationCode ¶
SendVerificationCode sends a verification code email to the user
func SendWithMailtrap ¶ added in v0.45.0
SendWithMailtrap sends email using Mailtrap SMTP
func ValidateResetToken ¶ added in v0.45.0
ValidateResetToken validates a password reset token. Checks that the token exists, has not been used (usedAt IS NULL), and has not expired. Returns the user ID associated with the token, or an error.
Types ¶
type EmailTemplate ¶ added in v0.33.0
EmailTemplate holds localized email content
func GetAdminNotificationTemplate ¶ added in v0.33.0
func GetAdminNotificationTemplate(lang, userName, userEmail, companyName string) EmailTemplate
GetAdminNotificationTemplate returns the localized admin notification template
func GetContractExpiryTemplate ¶ added in v0.45.0
func GetContractExpiryTemplate(contractNumber, daysLeft, expiryDate, contractName, clientName, companyName, contractID, adminEmail string) EmailTemplate
GetContractExpiryTemplate returns the contract expiry notification template
func GetPasswordResetTemplate ¶ added in v0.45.0
func GetPasswordResetTemplate(lang, resetLink, userName string) EmailTemplate
GetPasswordResetTemplate returns the localized password reset email template
func GetReportTemplate ¶ added in v0.45.0
func GetReportTemplate(reportDate string) EmailTemplate
GetReportTemplate returns the report email template
func GetVerificationTemplate ¶ added in v0.33.0
func GetVerificationTemplate(lang, code string) EmailTemplate
GetVerificationTemplate returns the localized verification email template
type SMTPConfig ¶ added in v0.45.0
SMTPConfig holds the configuration for Mailtrap SMTP client
func GetSMTPConfig ¶ added in v0.45.0
func GetSMTPConfig(db *sql.DB) (SMTPConfig, error)
GetSMTPConfig loads SMTP configuration from database or environment