package tfa import ( "fmt" "strings" "time" "clapclap/internal/auth/jwt" "clapclap/internal/email" "clapclap/internal/env" "clapclap/internal/uuid" ) // DispatchVerificationEmail generates a token and sends the verification email. // Notice it returns an error instead of logging it directly. func DispatchVerificationEmail(userID uuid.UUID, userEmail string) error { secret := env.C.JWT_SECRET clientURL := strings.TrimRight(env.C.API_URL, "/") tokenString, err := jwt.GenerateActionToken(secret, userID, "email_verification", 24*time.Hour) if err != nil { return fmt.Errorf("failed to generate verification token: %w", err) } verifyLink := fmt.Sprintf("%s/auth/verify-email?token=%s", clientURL, tokenString) htmlContent := fmt.Sprintf(`
Please click the button below to verify your email address. This link will expire in 24 hours.
Verify EmailIf you didn't request this, you can safely ignore this email.
We received a request to reset your password. Click the button below to choose a new one. This link will expire in 15 minutes.
Reset PasswordIf you didn't request a password reset, you can safely ignore this email.