mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-01-17 04:18:16 +01:00
Add tests for 'Auth#provideOneTimePasswordAsSecondFactor'
This commit is contained in:
parent
561d6cd450
commit
9cab58ecb4
@ -107,6 +107,22 @@ function processRequestData(\Delight\Auth\Auth $auth) {
|
||||
return 'too many requests';
|
||||
}
|
||||
}
|
||||
else if ($_POST['action'] === 'provideOneTimePasswordAsSecondFactor') {
|
||||
try {
|
||||
$auth->provideOneTimePasswordAsSecondFactor($_POST['otpValue']);
|
||||
|
||||
return 'ok';
|
||||
}
|
||||
catch (\Delight\Auth\InvalidOneTimePasswordException $e) {
|
||||
return 'invalid OTP';
|
||||
}
|
||||
catch (\Delight\Auth\NotLoggedInException $e) {
|
||||
return 'first factor not completed';
|
||||
}
|
||||
catch (\Delight\Auth\TooManyRequestsException $e) {
|
||||
return 'too many requests';
|
||||
}
|
||||
}
|
||||
else if ($_POST['action'] === 'register') {
|
||||
try {
|
||||
if ($_POST['require_verification'] == 1) {
|
||||
@ -978,6 +994,12 @@ function showGuestUserForm() {
|
||||
echo '<button type="submit">Log in with username</button>';
|
||||
echo '</form>';
|
||||
|
||||
echo '<form action="" method="post" accept-charset="utf-8">';
|
||||
echo '<input type="hidden" name="action" value="provideOneTimePasswordAsSecondFactor" />';
|
||||
echo '<input type="text" name="otpValue" placeholder="OTP value" /> ';
|
||||
echo '<button type="submit">Provide OTP</button>';
|
||||
echo '</form>';
|
||||
|
||||
echo '<form action="" method="post" accept-charset="utf-8">';
|
||||
echo '<input type="hidden" name="action" value="register" />';
|
||||
echo '<input type="text" name="email" placeholder="Email address" /> ';
|
||||
|
Loading…
x
Reference in New Issue
Block a user