mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-04 15:17:28 +02:00
Add tests for methods that let users enable or disable password resets
This commit is contained in:
@@ -243,6 +243,16 @@ function processRequestData(\Delight\Auth\Auth $auth) {
|
|||||||
return 'invalid password(s)';
|
return 'invalid password(s)';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ($_POST['action'] === 'setPasswordResetEnabled') {
|
||||||
|
try {
|
||||||
|
$auth->setPasswordResetEnabled($_POST['enabled'] == 1);
|
||||||
|
|
||||||
|
return 'ok';
|
||||||
|
}
|
||||||
|
catch (\Delight\Auth\NotLoggedInException $e) {
|
||||||
|
return 'not logged in';
|
||||||
|
}
|
||||||
|
}
|
||||||
else if ($_POST['action'] === 'logout') {
|
else if ($_POST['action'] === 'logout') {
|
||||||
$auth->logout();
|
$auth->logout();
|
||||||
|
|
||||||
@@ -523,6 +533,15 @@ function showAuthenticatedUserForm(\Delight\Auth\Auth $auth) {
|
|||||||
echo '<button type="submit">Change password</button>';
|
echo '<button type="submit">Change password</button>';
|
||||||
echo '</form>';
|
echo '</form>';
|
||||||
|
|
||||||
|
echo '<form action="" method="post" accept-charset="utf-8">';
|
||||||
|
echo '<input type="hidden" name="action" value="setPasswordResetEnabled" />';
|
||||||
|
echo '<select name="enabled" size="1">';
|
||||||
|
echo '<option value="0"' . ($auth->isPasswordResetEnabled() ? '' : ' selected="selected"') . '>Disabled</option>';
|
||||||
|
echo '<option value="1"' . ($auth->isPasswordResetEnabled() ? ' selected="selected"' : '') . '>Enabled</option>';
|
||||||
|
echo '</select> ';
|
||||||
|
echo '<button type="submit">Control password resets</button>';
|
||||||
|
echo '</form>';
|
||||||
|
|
||||||
echo '<form action="" method="post" accept-charset="utf-8">';
|
echo '<form action="" method="post" accept-charset="utf-8">';
|
||||||
echo '<input type="hidden" name="action" value="logout" />';
|
echo '<input type="hidden" name="action" value="logout" />';
|
||||||
echo '<button type="submit">Logout</button>';
|
echo '<button type="submit">Logout</button>';
|
||||||
|
Reference in New Issue
Block a user