Skip to content

Commit d7a87d2

Browse files
committed
fix: check for at least 8 characters for a password
1 parent 3e5c473 commit d7a87d2

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

phpmyfaq/admin/pwd.change.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,29 @@
5353
$newPassword = Filter::filterInput(INPUT_POST, 'npass', FILTER_UNSAFE_RAW);
5454
$retypedPassword = Filter::filterInput(INPUT_POST, 'bpass', FILTER_UNSAFE_RAW);
5555

56-
if (($authSource->checkCredentials($user->getLogin(), $oldPassword)) && ($newPassword == $retypedPassword)) {
57-
if (!$user->changePassword($newPassword)) {
56+
if (strlen($newPassword) <= 7 || strlen($retypedPassword) <= 7) {
57+
printf(
58+
'<p class="alert alert-danger"><button type="button" class="close" data-dismiss="alert">&times;</button>%s</p>',
59+
$PMF_LANG['ad_passwd_fail']
60+
);
61+
} else {
62+
if (($authSource->checkCredentials($user->getLogin(), $oldPassword)) && ($newPassword == $retypedPassword)) {
63+
if (!$user->changePassword($newPassword)) {
64+
printf(
65+
'<p class="alert alert-danger"><button type="button" class="close" data-dismiss="alert">&times;</button>%s</p>',
66+
$PMF_LANG['ad_passwd_fail']
67+
);
68+
}
69+
printf(
70+
'<p class="alert alert-success"><button type="button" class="close" data-dismiss="alert">&times;</button>%s</p>',
71+
$PMF_LANG['ad_passwdsuc']
72+
);
73+
} else {
5874
printf(
5975
'<p class="alert alert-danger"><button type="button" class="close" data-dismiss="alert">&times;</button>%s</p>',
6076
$PMF_LANG['ad_passwd_fail']
6177
);
6278
}
63-
printf(
64-
'<p class="alert alert-success"><button type="button" class="close" data-dismiss="alert">&times;</button>%s</p>',
65-
$PMF_LANG['ad_passwdsuc']
66-
);
67-
} else {
68-
printf(
69-
'<p class="alert alert-danger"><button type="button" class="close" data-dismiss="alert">&times;</button>%s</p>',
70-
$PMF_LANG['ad_passwd_fail']
71-
);
7279
}
7380
}
7481
?>

phpmyfaq/src/phpMyFAQ/Installer.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -845,14 +845,14 @@ public function startInstall(array $setup = null): void
845845
$esSetup = [];
846846
}
847847

848-
// check loginname
848+
// check login name
849849
if (!isset($setup['loginname'])) {
850850
$loginName = Filter::filterInput(INPUT_POST, 'loginname', FILTER_UNSAFE_RAW);
851851
} else {
852852
$loginName = $setup['loginname'];
853853
}
854854
if (is_null($loginName)) {
855-
echo '<p class="alert alert-danger"><strong>Error:</strong> Please add a loginname for your account.</p>';
855+
echo '<p class="alert alert-danger"><strong>Error:</strong> Please add a login name for your account.</p>';
856856
System::renderFooter(true);
857857
}
858858

@@ -863,8 +863,7 @@ public function startInstall(array $setup = null): void
863863
$password = $setup['password'];
864864
}
865865
if (is_null($password)) {
866-
echo '<p class="alert alert-danger"><strong>Error:</strong> Please add a password for the your ' .
867-
'account.</p>';
866+
echo '<p class="alert alert-danger"><strong>Error:</strong> Please add a password for your account.</p>';
868867
System::renderFooter(true);
869868
}
870869

@@ -873,16 +872,18 @@ public function startInstall(array $setup = null): void
873872
} else {
874873
$passwordRetyped = $setup['password_retyped'];
875874
}
875+
876876
if (is_null($passwordRetyped)) {
877877
echo '<p class="alert alert-danger"><strong>Error:</strong> Please add a retyped password.</p>';
878878
System::renderFooter(true);
879879
}
880880

881-
if (strlen($password) <= 5 || strlen($passwordRetyped) <= 5) {
881+
if (strlen($password) <= 7 || strlen($passwordRetyped) <= 7) {
882882
echo '<p class="alert alert-danger"><strong>Error:</strong> Your password and retyped password are too ' .
883883
'short. Please set your password and your retyped password with a minimum of 6 characters.</p>';
884884
System::renderFooter(true);
885885
}
886+
886887
if ($password != $passwordRetyped) {
887888
echo '<p class="alert alert-danger"><strong>Error:</strong> Your password and retyped password are not ' .
888889
'equal. Please check your password and your retyped password.</p>';

0 commit comments

Comments
 (0)