'; ?> getVerification(\Models\Verification::TYPE_2FA); } try { switch ($action) { case 'deliver': if (is_post()) { \App\Content::verifyPost(); // $to is dependent on the $method // $to = $_user->email; // or // $to = $_user->phone; $to = get('email', $_POST); $method = \Models\Verification::METHOD_EMAIL; $verification = $_user->createVerification(\Models\Verification::TYPE_2FA, $to, $method); try { $delivered = $verification->deliver(); if ($delivered) { // redirect i.e. refresh the page redirect(APP_URL.'/php_security_2fa.php'); } else { throw new Exception('Failed to deliver the code! Note that demo site is not setup with Twilio.'); } } catch (Exception $ex) { $verification = null; throw $ex; } } break; case 'reset': // delete the old verification if ($verification) { $verification->delete(); $verification = null; } break; case 'validate': if (is_post()) { \App\Content::verifyPost(); $code = get('code', $_POST); // in production, the following code instead // $session = \App\App::getSession(); // $session->verify2faCode($code); if ($code && $verification && $verification->validate($_user)) { $verified = $verification->verify($code); if ($verified) { // redirect to somewhere for a successful verification redirect(APP_URL.'/php_security_2fa.php?verified=1'); } else { throw new Exception('Invalid verification code'); } } else { throw new Exception('Invalid verification code'); } } break; } } catch (Exception $ex) { $exception = $ex->getMessage(); $defaults = $_POST; } ?>
Verification Success!
Your verificaton code is valid. Good job!', 'success') : null ?>

Thank you! Please check your inbox.

true]); $input->label('Enter Code') ->attr(['autofocus']) ->printHtml(); ?>

For demo purposes, enter the email you want to receive the 2FA code.

true]); $input->label('Enter Email') ->value(get('email', $defaults)) ->placeholder('youremail@domain.com') ->attr(['autofocus']) ->help('Phone is not supported by this demo') ->printHtml(); ?>
Not authenticated
Redirecting in 5 seconds...', 'danger') ?>
2020 © SmartAdmin for PHP by @lodev09