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 {
- + @@ -11229,7 +11229,7 @@ class AccountManager {
- + @@ -11311,8 +11311,8 @@ class AccountManager { return; } - if (newPassword && (newPassword.length < 12 || newPassword.length > 256)) { - this.notifyFailure('New password must be between 12 and 256 characters'); + if (newPassword && (newPassword.length < 6 || newPassword.length > 256)) { + this.notifyFailure('New password must be between 6 and 256 characters'); return; } @@ -11735,7 +11735,7 @@ class AccountManager {
- + @@ -11817,8 +11817,8 @@ class AccountManager { return; } - if (password && (password.length < 12 || password.length > 256)) { - this.notifyFailure('Password must be between 12 and 256 characters'); + if (password && (password.length < 6 || password.length > 256)) { + this.notifyFailure('Password must be between 6 and 256 characters'); return; } diff --git a/public/pages/login.html b/public/pages/login.html index 936d9e2..0ec2b13 100644 --- a/public/pages/login.html +++ b/public/pages/login.html @@ -193,7 +193,7 @@ id="resetPassword" name="resetPassword" placeholder="Enter a new password" - minlength="12" + minlength="6" maxlength="256" required class="w-full pl-10 pr-4 py-2.5 bg-surface-container-low border border-outline-variant/30 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent transition-all text-sm font-medium" @@ -212,7 +212,7 @@ id="resetConfirmPassword" name="resetConfirmPassword" placeholder="Re-enter new password" - minlength="12" + minlength="6" maxlength="256" required class="w-full pl-10 pr-4 py-2.5 bg-surface-container-low border border-outline-variant/30 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent transition-all text-sm font-medium" @@ -297,7 +297,7 @@ id="regPassword" name="password" placeholder="Create a password" - minlength="12" + minlength="6" maxlength="256" required class="w-full pl-10 pr-4 py-2.5 bg-surface-container-low border border-outline-variant/30 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent transition-all text-sm font-medium" @@ -608,8 +608,8 @@ return; } - if (!newPassword || newPassword.length < 12 || newPassword.length > 256) { - resetPasswordErrorMessage.textContent = 'New password must be between 12 and 256 characters.'; + if (!newPassword || newPassword.length < 6 || newPassword.length > 256) { + resetPasswordErrorMessage.textContent = 'New password must be between 6 and 256 characters.'; resetPasswordErrorMessage.classList.remove('hidden'); return; }