diff --git a/phpmyfaq/admin/ajax.user.php b/phpmyfaq/admin/ajax.user.php index 13f2bdf19b..7d15ca8e29 100644 --- a/phpmyfaq/admin/ajax.user.php +++ b/phpmyfaq/admin/ajax.user.php @@ -120,6 +120,7 @@ $userName = Filter::filterVar($postData['userName'], FILTER_UNSAFE_RAW); $userRealName = Filter::filterVar($postData['realName'], FILTER_UNSAFE_RAW); $userEmail = Filter::filterVar($postData['email'], FILTER_VALIDATE_EMAIL); + $automaticPassword = Filter::filterVar($postData['automaticPassword'], FILTER_VALIDATE_BOOLEAN); $userPassword = Filter::filterVar($postData['password'], FILTER_UNSAFE_RAW); $userPasswordConfirm = Filter::filterVar($postData['passwordConfirm'], FILTER_UNSAFE_RAW); $userIsSuperAdmin = Filter::filterVar($postData['isSuperAdmin'], FILTER_VALIDATE_BOOLEAN); @@ -138,6 +139,12 @@ if (is_null($userEmail)) { $errorMessage[] = $PMF_LANG['ad_user_error_noEmail']; } + if (!$automaticPassword) { + if (strlen($userPassword) <= 7 || strlen($userPasswordConfirm) <= 7) { + $errorMessage[] = $PMF_LANG['ad_passwd_fail']; + } + } + if (count($errorMessage) === 0) { if (!$newUser->createUser($userName, $userPassword)) { $errorMessage[] = $newUser->error(); @@ -204,6 +211,12 @@ exit(1); } + if (strlen($newPassword) <= 7 || strlen($retypedPassword) <= 7) { + $http->setStatus(400); + $http->sendJsonWithHeaders(['error' => $PMF_LANG['ad_passwd_fail']]); + exit(1); + } + $user->getUserById($userId, true); $auth = new Auth($faqConfig); $authSource = $auth->selectAuth($user->getAuthSource('name')); diff --git a/phpmyfaq/admin/assets/js/user.js b/phpmyfaq/admin/assets/js/user.js index cc5d0cc26e..0c960bb2ac 100644 --- a/phpmyfaq/admin/assets/js/user.js +++ b/phpmyfaq/admin/assets/js/user.js @@ -157,6 +157,7 @@ document.addEventListener('DOMContentLoaded', () => { const userName = document.getElementById('add_user_name').value; const realName = document.getElementById('add_user_realname').value; const email = document.getElementById('add_user_email').value; + const automaticPassword = document.getElementById('add_user_automatic_password').checked; const password = document.getElementById('add_user_password').value; const passwordConfirm = document.getElementById('add_user_password_confirm').value; const isSuperAdmin = document.querySelector('#add_user_is_superadmin').checked; @@ -167,6 +168,7 @@ document.addEventListener('DOMContentLoaded', () => { userName, realName, email, + automaticPassword, password, passwordConfirm, isSuperAdmin, diff --git a/phpmyfaq/admin/user.php b/phpmyfaq/admin/user.php index 95f877d0c0..6a2f83ca1e 100755 --- a/phpmyfaq/admin/user.php +++ b/phpmyfaq/admin/user.php @@ -444,7 +444,8 @@ class="form-check-input permission"> = $PMF_LANG['ad_passwd_new'] ?>