// Initialize the authenticator $authenticator = new Gdn_Authenticator(); // Check if user is already logged in if ($authenticator->authenticated()) { // Proceed to logged-in area // ... } else { // Get user's credentials $username = $_POST['username']; $password = $_POST['password']; // Check if credentials are valid if ($authenticator->verifyCredentials($username, $password)) { // Send code to user's mobile device or email $code = $authenticator->sendCode($user); // Prompt user to enter code $enteredCode = $_POST['code']; // Authenticate the user if code is correct if ($authenticator->verifyCode($user, $enteredCode)) { $authenticator->authenticate($user); // Proceed to logged-in area // ... } else { // Prompt user to enter code again // ... } } else { // Prompt user to enter credentials again // ... } }
// Initialize the authenticator $authenticator = new Gdn_Authenticator(); // Check if user is already logged in if ($authenticator->authenticated()) { // Prompt user to enter code $code = $authenticator->sendCode($user); // or $authenticator->generateCode($user); // Verify code entered by user $enteredCode = $_POST['code']; if ($authenticator->verifyCode($user, $enteredCode)) { // Allow user to access admin panel // ... } else { // Prompt user to enter code again // ... } } else { // Redirect to login page // ... }In both examples, the php Gdn Authenticator library is used to provide an extra layer of security to the web application.