fix: resolve super_admin auto-provisioning timing issue on fresh stacks
All checks were successful
Build and Deploy / build-and-push (push) Successful in 1m2s
All checks were successful
Build and Deploy / build-and-push (push) Successful in 1m2s
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user