diff --git a/backend/index.js b/backend/index.js index dbeac0e..c227afb 100644 --- a/backend/index.js +++ b/backend/index.js @@ -609,7 +609,7 @@ if (process.env.NODE_ENV === 'production') { } // Auto-provision Super Admin -const provisionSuperAdmin = async (retries = 5, delay = 5000) => { +const provisionSuperAdmin = async (retries = 10, delay = 10000) => { const email = 'suporte@blyzer.com.br'; for (let i = 0; i < retries; i++) { @@ -636,12 +636,15 @@ const provisionSuperAdmin = async (retries = 5, delay = 5000) => { } const token = crypto.randomBytes(32).toString('hex'); + // Delete any old unused tokens for this email to prevent buildup + await pool.query('DELETE FROM password_resets WHERE email = ?', [email]); + await pool.query( 'INSERT INTO password_resets (email, token, expires_at) VALUES (?, ?, DATE_ADD(NOW(), INTERVAL 15 MINUTE))', [email, token] ); - const setupLink = `${process.env.APP_URL || 'http://localhost:3001'}/#/reset-password?token=${token}`; + const setupLink = `${process.env.APP_URL || 'http://localhost:3001'}/#/setup-account?token=${token}`; console.log(`\n\n=== SUPER ADMIN SETUP LINK ===\n${setupLink}\n==============================\n\n`); await transporter.sendMail({