From 0016c68a7ce843ab2e248937c41c8c2b73de2d76 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sun, 18 Jun 2023 21:36:59 +0200 Subject: [PATCH] Final fixes --- src/Lang.php | 2 ++ src/Wrappers/Start.php | 2 +- src/Wrappers/Templates.php | 39 +++++++++++++++++++++++++++----------- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/Lang.php b/src/Lang.php index f8927c184..4f700739d 100644 --- a/src/Lang.php +++ b/src/Lang.php @@ -156,6 +156,7 @@ final class Lang 'signupWeb' => 'Registrazione', 'go' => 'Vai', 'loginChoosePromptWeb' => 'Vuoi effettuare il login come utente o come bot?', + 'loginWebQr' => 'Puoi anche effettuare il login automaticamente scansionando il seguente codice QR:', 'loginOptionBot' => 'Bot', 'loginOptionUser' => 'Utente', 'loginBotTokenWeb' => 'Token del bot', @@ -175,6 +176,7 @@ final class Lang [ 'go' => 'Go', 'loginChoosePromptWeb' => 'Do you want to login as a user or as a bot?', + 'loginWebQr' => 'You can also login automatically by scanning the following QR code:', 'loginOptionBot' => 'Bot', 'loginOptionUser' => 'User', 'apiChooseManualAutoTip' => 'Note that you can also provide the API ID/hash directly in the code using the settings: %s', diff --git a/src/Wrappers/Start.php b/src/Wrappers/Start.php index 983b50965..cf95fa286 100644 --- a/src/Wrappers/Start.php +++ b/src/Wrappers/Start.php @@ -123,7 +123,7 @@ trait Start if (isset($_POST['password'])) { $this->webComplete2faLogin(); } else { - $this->webEcho(Lang::$current_lang['loginNoPass']); + $this->webEcho(Lang::$current_lang['loginUserPassWeb']); } } elseif ($this->getAuthorization() === MTProto::WAITING_SIGNUP) { if (isset($_POST['first_name'])) { diff --git a/src/Wrappers/Templates.php b/src/Wrappers/Templates.php index 64d573e74..ba20080cf 100644 --- a/src/Wrappers/Templates.php +++ b/src/Wrappers/Templates.php @@ -54,13 +54,14 @@ trait Templates $token = \htmlentities(Lang::$current_lang['loginBotTokenWeb']); $form = ""; } - } elseif (isset($_GET['waitQrCodeOrLogin'])) { + } elseif (isset($_GET['waitQrCodeOrLogin']) || isset($_GET['getQrCode'])) { header('Content-type: application/json'); try { /** @var ?LoginQrCode */ - $qr = $this->qrLogin()?->waitForLoginOrQrCodeExpiration(new TimeoutCancellation( - 5.0 - )); + $qr = $this->qrLogin(); + if (isset($_GET['waitQrCodeOrLogin'])) { + $qr = $qr?->waitForLoginOrQrCodeExpiration(new TimeoutCancellation(5.0)); + } } catch (CancelledException) { /** @var ?LoginQrCode */ $qr = $this->qrLogin(); @@ -81,13 +82,29 @@ trait Templates $title = Lang::$current_lang['loginChoosePromptWeb']; $optionBot = \htmlentities(Lang::$current_lang['loginOptionBot']); $optionUser = \htmlentities(Lang::$current_lang['loginOptionUser']); - $trailer = '
'; $form = ""; }