export const emailVerificationConfig = { id: 'email-verification', name: 'Email Verification', description: 'Verify user emails before allowing them to log in', category: 'spam', } export const expiryOptions = [ { value: '1', label: '1 hour' }, { value: '3', label: '3 hours' }, { value: '6', label: '6 hours' }, { value: '12', label: '12 hours' }, { value: '24', label: '24 hours' }, { value: '48', label: '48 hours' }, { value: '72', label: '72 hours' }, ] export const autoDeleteOptions = [ { value: '0', label: 'Never' }, { value: '24', label: '24 hours' }, { value: '48', label: '48 hours' }, { value: '72', label: '72 hours' }, { value: '168', label: '7 days' }, { value: '336', label: '14 days' }, { value: '720', label: '30 days' }, ] export const resendLimitOptions = [ { value: '0', label: 'Unlimited' }, { value: '3', label: '3 times' }, { value: '5', label: '5 times' }, { value: '10', label: '10 times' }, ] export const verificationModeOptions = [ { value: 'email_verification', label: 'Email Verification', description: 'Users receive a verification link and verify themselves' }, { value: 'admin_approval', label: 'Admin Approval', description: 'Users wait for manual admin approval' }, ] export const defaultEmailTemplate = { subject: 'Verify your email address - {{site_name}}', body: `Hi {{user_name}}, Thank you for creating an account with us. Please verify your email address by clicking the button below: {{verification_link}} This link will expire in {{expiry_time}}. If you did not create an account, please ignore this email. Best regards, {{site_name}}`, } export const defaultPendingApprovalEmailTemplate = { subject: 'Your account is pending approval - {{site_name}}', body: `Hi {{user_name}}, Thank you for creating an account at {{site_name}}. Your account is currently pending approval by our team. You will receive an email once your account has been approved. If you have any questions, please contact us. Best regards, {{site_name}}`, } export const defaultAccountApprovedEmailTemplate = { subject: 'Your account has been approved - {{site_name}}', body: `Hi {{user_name}}, Great news! Your account at {{site_name}} has been approved. You can now log in using the link below: {{login_link}} Best regards, {{site_name}}`, } export const defaultAdminNotificationEmailTemplate = { subject: 'New user registration pending approval - {{site_name}}', body: `A new user has registered and is waiting for approval. Username: {{user_name}} Email: {{user_email}} You can review and approve this user from the Email Verification settings in your Swift Commerce dashboard. {{admin_link}}`, } export const defaultAccountRejectedEmailTemplate = { subject: 'Your account registration update - {{site_name}}', body: `Hi {{user_name}}, Thank you for your interest in {{site_name}}. Unfortunately, we are unable to approve your account registration at this time. If you believe this is an error or have any questions, please contact us. Best regards, {{site_name}}`, } export const emailPlaceholders = [ { tag: '{{user_name}}', description: 'User\'s display name' }, { tag: '{{user_email}}', description: 'User\'s email address' }, { tag: '{{verification_link}}', description: 'The verification link/button' }, { tag: '{{site_name}}', description: 'Your website name' }, { tag: '{{site_url}}', description: 'Your website URL' }, { tag: '{{expiry_time}}', description: 'Time until link expires' }, ] export interface EmailVerificationSettings { enabled: boolean verificationMode: 'email_verification' | 'admin_approval' enableForRegistration: boolean enableForWooCommerceRegistration: boolean enableForGuestCheckout: boolean enableForLoggedInCheckout: boolean linkExpiry: string resendLimit: string autoDeleteAfter: string skipRoles: string[] emailSubject: string emailBody: string emailHeading: string emailAdditionalContent: string emailPreheaderText: string // Email enable/disable toggles sendVerificationEmail: boolean sendPendingApprovalEmail: boolean sendAccountApprovedEmail: boolean sendAdminNotificationEmail: boolean sendAccountRejectedEmail: boolean // Admin Approval email templates (Pro) pendingApprovalEmailSubject: string pendingApprovalEmailBody: string pendingApprovalEmailHeading: string accountApprovedEmailSubject: string accountApprovedEmailBody: string accountApprovedEmailHeading: string adminNotificationEmailSubject: string adminNotificationEmailBody: string adminNotificationEmailHeading: string // Account Rejected email template (Pro) accountRejectedEmailSubject: string accountRejectedEmailBody: string accountRejectedEmailHeading: string // Redirect after verification (Pro) redirectAfterVerification: string } export interface PendingUser { id: number username: string email: string registeredAt: string expiresAt: string resendCount: number status: 'pending' | 'verified' verificationSentAt?: string } export const defaultSettings: EmailVerificationSettings = { enabled: false, verificationMode: 'email_verification', enableForRegistration: true, enableForWooCommerceRegistration: false, enableForGuestCheckout: false, enableForLoggedInCheckout: false, linkExpiry: '24', resendLimit: '5', autoDeleteAfter: '0', skipRoles: ['administrator'], emailSubject: defaultEmailTemplate.subject, emailBody: defaultEmailTemplate.body, emailHeading: 'Verify Your Email Address', emailAdditionalContent: '', emailPreheaderText: '', // Email enable/disable toggles sendVerificationEmail: true, sendPendingApprovalEmail: true, sendAccountApprovedEmail: true, sendAdminNotificationEmail: true, sendAccountRejectedEmail: true, // Admin Approval email templates (Pro) pendingApprovalEmailSubject: defaultPendingApprovalEmailTemplate.subject, pendingApprovalEmailBody: defaultPendingApprovalEmailTemplate.body, pendingApprovalEmailHeading: 'Account Pending Approval', accountApprovedEmailSubject: defaultAccountApprovedEmailTemplate.subject, accountApprovedEmailBody: defaultAccountApprovedEmailTemplate.body, accountApprovedEmailHeading: 'Account Approved', adminNotificationEmailSubject: defaultAdminNotificationEmailTemplate.subject, adminNotificationEmailBody: defaultAdminNotificationEmailTemplate.body, adminNotificationEmailHeading: 'New Registration Pending Approval', // Account Rejected email template (Pro) accountRejectedEmailSubject: defaultAccountRejectedEmailTemplate.subject, accountRejectedEmailBody: defaultAccountRejectedEmailTemplate.body, accountRejectedEmailHeading: 'Registration Update', // Redirect after verification (Pro) redirectAfterVerification: '', } export const wordpressRoles = [ { value: 'administrator', label: 'Administrator' }, { value: 'editor', label: 'Editor' }, { value: 'author', label: 'Author' }, { value: 'contributor', label: 'Contributor' }, { value: 'subscriber', label: 'Subscriber' }, { value: 'customer', label: 'Customer (WooCommerce)' }, { value: 'shop_manager', label: 'Shop Manager (WooCommerce)' }, ]