get('otp'); $repository = new \Database(0); // remove old request (> 24 hours) $repository->exec_sql("delete from otp_send_secret where os_timestamp < now()-interval '12 hours'"); // check if UUID exist $id = $repository->get_value("select os_id from otp_send_secret where os_request=$1", [$uuid]); // if UUID doesn't exist exit if ($repository->count() == 0) { echo _("Expiré : vous devez redemander le renvoi de la clef"); return; } // get email from id $otp_send = new Otp_Send_Secret_SQL($repository, $id); $user = new Noalyss_User($repository, $otp_send->get('use_id')); $secret = $user->get_otp_secret(); // OTP $authenticator = new \Noalyss\OTP(); $authenticator->get_authenticator()->setSecret($secret); $data= $authenticator->get_authenticator()->getUri(label:"noalyss:".$user->getEmail(),issuer:"noalyss.eu"); // load secret for this id //echo "use with php -S localhost:5000 puis ouvrir index.html "; $writer = new PngWriter(); // Create QR code $qrCode = new QrCode( data: $data, encoding: new Encoding('UTF-8'), errorCorrectionLevel: ErrorCorrectionLevel::Medium, size: 600, margin: 10, roundBlockSizeMode: RoundBlockSizeMode::Margin, foregroundColor: new Color(0, 0, 0), backgroundColor: new Color(255, 255, 255) ); $result = $writer->write($qrCode); echo '
'; // generate the QRCode echo '

',_("Scanner ceci avec votre application OTP"),'

'; ?>
  1. FreeOTP (libre)
  2. AEgis Authenticator (libre)
  3. Google Authenticator
'; echo _("Scanner ce QRCode avec votre application OTP afin de l'ajouter"); if ( DEBUGNOALYSS > 1) { echo "code attendu",$authenticator->code();} echo '

'; printf('', base64_encode($result->getString())); } catch (Exception $exc) { record_log($e); return; } ?>