update pass

This commit is contained in:
2026-09-30 10:09:08 +07:00
parent 3201a18fd4
commit dff0d32912
4 changed files with 26 additions and 24 deletions

2
.gitignore vendored
View File

@@ -7,3 +7,5 @@ docs-output
scripts
.codex-server.err.log
.codex-server.out.log
tmp

View File

@@ -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

View File

@@ -11219,7 +11219,7 @@ class AccountManager {
<div>
<label class="block text-xs font-semibold text-slate-600 dark:text-slate-300 mb-1">New password</label>
<div class="flex items-center gap-2">
<input type="password" id="profileNewPassword" placeholder="At least 12 characters" minlength="12" maxlength="256" class="flex-1 px-3 py-2 border border-outline-variant/30 rounded-lg bg-white dark:bg-slate-900">
<input type="password" id="profileNewPassword" placeholder="At least 6 characters" minlength="6" maxlength="256" class="flex-1 px-3 py-2 border border-outline-variant/30 rounded-lg bg-white dark:bg-slate-900">
<button type="button" data-password-toggle="profileNewPassword" class="shrink-0 px-2.5 py-2 border border-outline-variant/30 rounded-lg text-slate-500 hover:text-slate-700 hover:bg-slate-100 dark:hover:text-slate-200 dark:hover:bg-slate-800" aria-label="Show new password">
<span class="material-symbols-outlined text-base" id="profileNewPasswordIcon">visibility</span>
</button>
@@ -11229,7 +11229,7 @@ class AccountManager {
<div>
<label class="block text-xs font-semibold text-slate-600 dark:text-slate-300 mb-1">Confirm new password</label>
<div class="flex items-center gap-2">
<input type="password" id="profileConfirmPassword" placeholder="Confirm new password" minlength="12" maxlength="256" class="flex-1 px-3 py-2 border border-outline-variant/30 rounded-lg bg-white dark:bg-slate-900">
<input type="password" id="profileConfirmPassword" placeholder="Confirm new password" minlength="6" maxlength="256" class="flex-1 px-3 py-2 border border-outline-variant/30 rounded-lg bg-white dark:bg-slate-900">
<button type="button" data-password-toggle="profileConfirmPassword" class="shrink-0 px-2.5 py-2 border border-outline-variant/30 rounded-lg text-slate-500 hover:text-slate-700 hover:bg-slate-100 dark:hover:text-slate-200 dark:hover:bg-slate-800" aria-label="Show confirm password">
<span class="material-symbols-outlined text-base" id="profileConfirmPasswordIcon">visibility</span>
</button>
@@ -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 {
<div>
<label class="block text-sm font-medium mb-1">${user ? 'New Password' : 'Password'}</label>
<div class="flex items-center gap-2">
<input type="password" id="userPassword" placeholder="${user ? 'Leave blank to keep current password' : 'At least 12 characters'}" minlength="12" maxlength="256" class="flex-1 px-3 py-2 border border-outline-variant/30 rounded-lg bg-surface-container-low dark:bg-slate-800" ${user ? '' : 'required'}>
<input type="password" id="userPassword" placeholder="${user ? 'Leave blank to keep current password' : 'At least 6 characters'}" minlength="6" maxlength="256" class="flex-1 px-3 py-2 border border-outline-variant/30 rounded-lg bg-surface-container-low dark:bg-slate-800" ${user ? '' : 'required'}>
<button type="button" id="userPasswordToggle" class="p-2 rounded-lg border border-outline-variant/30 hover:bg-slate-100 dark:hover:bg-slate-700" title="Show/Hide password">
<span class="material-symbols-outlined text-base" id="userPasswordToggleIcon">visibility</span>
</button>
@@ -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;
}

View File

@@ -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;
}