isGuest()) { UI::exitError(getMLText("2_factor_auth"),getMLText("access_denied")); } $action = !empty($_POST['action']) ? $_POST['action'] : ''; switch($action) { case "test": if($user->getSecret()) { $tfa = new \RobThree\Auth\TwoFactorAuth(new \RobThree\Auth\Providers\Qr\BaconQrCodeProvider()); header('Content-Type: application/json'); if($tfa->verifyCode($user->getSecret(), $_POST['code']) !== true) { echo json_encode(array('success'=>false, 'message'=>getMLText("2_factor_auth_test_failed"), 'data'=>$_POST['code'])); } else { echo json_encode(array('success'=>true, 'message'=>getMLText("2_factor_auth_test_succeeded"))); } exit; } break; case "removesecret": if(!checkFormKey('removesecret')) { UI::exitError(getMLText("2_factor_auth"),getMLText("invalid_request_token")); } if(empty($_POST['confirm'])) { $session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('2_factor_auth_rm_secret_no_confirm'))); } else { $user->setSecret(''); } header("Location:../out/out.Setup2Factor.php"); break; default: $secret = $_POST["secret"]; $user->setSecret($secret); header("Location:../out/out.Setup2Factor.php"); }