mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-06 08:07:27 +02:00
Add tests for method 'changePasswordWithoutOldPassword' from 'Auth'
This commit is contained in:
@@ -246,6 +246,19 @@ function processRequestData(\Delight\Auth\Auth $auth) {
|
|||||||
return 'invalid password(s)';
|
return 'invalid password(s)';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ($_POST['action'] === 'changePasswordWithoutOldPassword') {
|
||||||
|
try {
|
||||||
|
$auth->changePasswordWithoutOldPassword($_POST['newPassword']);
|
||||||
|
|
||||||
|
return 'ok';
|
||||||
|
}
|
||||||
|
catch (\Delight\Auth\NotLoggedInException $e) {
|
||||||
|
return 'not logged in';
|
||||||
|
}
|
||||||
|
catch (\Delight\Auth\InvalidPasswordException $e) {
|
||||||
|
return 'invalid password';
|
||||||
|
}
|
||||||
|
}
|
||||||
else if ($_POST['action'] === 'changeEmail') {
|
else if ($_POST['action'] === 'changeEmail') {
|
||||||
try {
|
try {
|
||||||
$auth->changeEmail($_POST['newEmail'], function ($selector, $token) {
|
$auth->changeEmail($_POST['newEmail'], function ($selector, $token) {
|
||||||
@@ -567,6 +580,12 @@ 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="changePasswordWithoutOldPassword" />';
|
||||||
|
echo '<input type="text" name="newPassword" placeholder="New password" /> ';
|
||||||
|
echo '<button type="submit">Change password without old password</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="changeEmail" />';
|
echo '<input type="hidden" name="action" value="changeEmail" />';
|
||||||
echo '<input type="text" name="newEmail" placeholder="New email address" /> ';
|
echo '<input type="text" name="newEmail" placeholder="New email address" /> ';
|
||||||
|
Reference in New Issue
Block a user