mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-02 06:10:14 +02:00
Add tests for re-sending confirmation requests with class 'Auth'
This commit is contained in:
@@ -172,6 +172,56 @@ function processRequestData(\Delight\Auth\Auth $auth) {
|
|||||||
return 'too many requests';
|
return 'too many requests';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ($_POST['action'] === 'resendConfirmationForEmail') {
|
||||||
|
try {
|
||||||
|
$auth->resendConfirmationForEmail($_POST['email'], function ($selector, $token) {
|
||||||
|
echo '<pre>';
|
||||||
|
echo 'Email confirmation';
|
||||||
|
echo "\n";
|
||||||
|
echo ' > Selector';
|
||||||
|
echo "\t\t\t\t";
|
||||||
|
echo htmlspecialchars($selector);
|
||||||
|
echo "\n";
|
||||||
|
echo ' > Token';
|
||||||
|
echo "\t\t\t\t";
|
||||||
|
echo htmlspecialchars($token);
|
||||||
|
echo '</pre>';
|
||||||
|
});
|
||||||
|
|
||||||
|
return 'ok';
|
||||||
|
}
|
||||||
|
catch (\Delight\Auth\ConfirmationRequestNotFound $e) {
|
||||||
|
return 'no request found';
|
||||||
|
}
|
||||||
|
catch (\Delight\Auth\TooManyRequestsException $e) {
|
||||||
|
return 'too many requests';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ($_POST['action'] === 'resendConfirmationForUserId') {
|
||||||
|
try {
|
||||||
|
$auth->resendConfirmationForUserId($_POST['userId'], function ($selector, $token) {
|
||||||
|
echo '<pre>';
|
||||||
|
echo 'Email confirmation';
|
||||||
|
echo "\n";
|
||||||
|
echo ' > Selector';
|
||||||
|
echo "\t\t\t\t";
|
||||||
|
echo htmlspecialchars($selector);
|
||||||
|
echo "\n";
|
||||||
|
echo ' > Token';
|
||||||
|
echo "\t\t\t\t";
|
||||||
|
echo htmlspecialchars($token);
|
||||||
|
echo '</pre>';
|
||||||
|
});
|
||||||
|
|
||||||
|
return 'ok';
|
||||||
|
}
|
||||||
|
catch (\Delight\Auth\ConfirmationRequestNotFound $e) {
|
||||||
|
return 'no request found';
|
||||||
|
}
|
||||||
|
catch (\Delight\Auth\TooManyRequestsException $e) {
|
||||||
|
return 'too many requests';
|
||||||
|
}
|
||||||
|
}
|
||||||
else if ($_POST['action'] === 'forgotPassword') {
|
else if ($_POST['action'] === 'forgotPassword') {
|
||||||
try {
|
try {
|
||||||
$auth->forgotPassword($_POST['email'], function ($selector, $token) {
|
$auth->forgotPassword($_POST['email'], function ($selector, $token) {
|
||||||
@@ -762,6 +812,18 @@ function showConfirmEmailForm() {
|
|||||||
echo '</select> ';
|
echo '</select> ';
|
||||||
echo '<button type="submit">Confirm email</button>';
|
echo '<button type="submit">Confirm email</button>';
|
||||||
echo '</form>';
|
echo '</form>';
|
||||||
|
|
||||||
|
echo '<form action="" method="post" accept-charset="utf-8">';
|
||||||
|
echo '<input type="hidden" name="action" value="resendConfirmationForEmail" />';
|
||||||
|
echo '<input type="text" name="email" placeholder="Email" /> ';
|
||||||
|
echo '<button type="submit">Re-send confirmation</button>';
|
||||||
|
echo '</form>';
|
||||||
|
|
||||||
|
echo '<form action="" method="post" accept-charset="utf-8">';
|
||||||
|
echo '<input type="hidden" name="action" value="resendConfirmationForUserId" />';
|
||||||
|
echo '<input type="text" name="userId" placeholder="User ID" /> ';
|
||||||
|
echo '<button type="submit">Re-send confirmation</button>';
|
||||||
|
echo '</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function createRolesOptions() {
|
function createRolesOptions() {
|
||||||
|
Reference in New Issue
Block a user