diff --git a/.gitignore b/.gitignore index 3db1449..938ed0b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ docs-output scripts .codex-server.err.log .codex-server.out.log +tmp + diff --git a/backend/server.js b/backend/server.js index af21081..6b2f8aa 100644 --- a/backend/server.js +++ b/backend/server.js @@ -3619,8 +3619,8 @@ async function createTables() { try { const initialAdminPassword = String(process.env.INITIAL_ADMIN_PASSWORD || ''); if (initialAdminPassword) { - if (initialAdminPassword.length < 12) { - throw new Error('INITIAL_ADMIN_PASSWORD must contain at least 12 characters'); + if (initialAdminPassword.length < 6) { + throw new Error('INITIAL_ADMIN_PASSWORD must contain at least 6 characters'); } const result = await pool.request() @@ -3784,8 +3784,8 @@ app.post('/api/auth/register', accountRecoveryRateLimit, async (req, res) => { if (!/^[A-Za-z0-9._-]{3,50}$/.test(safeUsername)) { return res.status(400).json({ success: false, message: 'Username must be 3-50 characters and contain only letters, numbers, dot, underscore or hyphen' }); } - if (safePassword.length < 12 || safePassword.length > 256) { - return res.status(400).json({ success: false, message: 'Password must be between 12 and 256 characters' }); + if (safePassword.length < 6 || safePassword.length > 256) { + return res.status(400).json({ success: false, message: 'Password must be between 6 and 256 characters' }); } const isEmailFormatValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(normalizedEmail); if (!isEmailFormatValid) { @@ -4120,8 +4120,8 @@ app.post('/api/auth/reset-password', accountRecoveryRateLimit, async (req, res) return res.status(400).json({ success: false, message: 'Reset token and new password are required' }); } - if (newPassword.length < 12 || newPassword.length > 256) { - return res.status(400).json({ success: false, message: 'New password must be between 12 and 256 characters' }); + if (newPassword.length < 6 || newPassword.length > 256) { + return res.status(400).json({ success: false, message: 'New password must be between 6 and 256 characters' }); } const tokenHash = hashVerificationToken(token); @@ -4724,8 +4724,8 @@ app.put('/api/users/me', async (req, res) => { const emailChanged = String(existingUser.Email || '').toLowerCase() !== incomingEmail; const shouldChangePassword = newPassword.length > 0; - if (shouldChangePassword && (newPassword.length < 12 || newPassword.length > 256)) { - return res.status(400).json({ success: false, message: 'New password must be between 12 and 256 characters' }); + if (shouldChangePassword && (newPassword.length < 6 || newPassword.length > 256)) { + return res.status(400).json({ success: false, message: 'New password must be between 6 and 256 characters' }); } if (shouldChangePassword || emailChanged) { @@ -4861,8 +4861,8 @@ app.post('/api/users', requireAdmin, async (req, res) => { if (!/^[A-Za-z0-9._-]{3,50}$/.test(String(username).trim())) { return res.status(400).json({ success: false, message: 'Username format is invalid' }); } - if (String(password).length < 12 || String(password).length > 256) { - return res.status(400).json({ success: false, message: 'Password must be between 12 and 256 characters' }); + if (String(password).length < 6 || String(password).length > 256) { + return res.status(400).json({ success: false, message: 'Password must be between 6 and 256 characters' }); } const hashedPassword = await hashPassword(password); @@ -4909,8 +4909,8 @@ app.put('/api/users/:id', requireAdmin, async (req, res) => { const { email, fullname, roleId, status, isActive, password } = req.body; const nextPassword = typeof password === 'string' ? password.trim() : ''; const shouldUpdatePassword = nextPassword.length > 0; - if (shouldUpdatePassword && (nextPassword.length < 12 || nextPassword.length > 256)) { - return res.status(400).json({ success: false, message: 'Password must be between 12 and 256 characters' }); + if (shouldUpdatePassword && (nextPassword.length < 6 || nextPassword.length > 256)) { + return res.status(400).json({ success: false, message: 'Password must be between 6 and 256 characters' }); } // Get role name from Roles table diff --git a/public/js/app.js b/public/js/app.js index 66d0adf..9a446f4 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -11219,7 +11219,7 @@ class AccountManager {