Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Verification Code Sent After Running the Code for Login Authorization in Version 8.4.1 #1599

Open
zxcItem opened this issue Jan 5, 2025 · 0 comments

Comments

@zxcItem
Copy link

zxcItem commented Jan 5, 2025

I have installed the latest version (8.4.1) of the code. I am trying to implement a login authorization feature that sends a verification code through the web interface. However, after running the code, no verification code is being sent. Can you please help me review my code to see if there is an issue?

`
/**
* Session invalidation rendering verification code form
*/
public function login()
{
try {
$data = $this->vali(['telegram_id.require' => 'Account ID cannot be empty!']);
$account = PluginTelegramAccount::getTelegramId($data['telegram_id']);
$session_file = syspath('madeline')."\session
{$data['telegram_id']}.madeline";
if (!file_exists($session_file)) {
$settings = new Settings;
$appInfo = (new \danog\MadelineProto\Settings\AppInfo())->setApiId(intval($account['api_id']))->setApiHash($account['api_hash']);
$settings->setAppInfo($appInfo);
$MadelineProto =new \danog\MadelineProto\API($session_file,$settings);
$response = $MadelineProto->phoneLogin($account['phone_number']);
$this->fetch('sms_code',['vo' => $account]);
}else{
$this->success('Authorized, no need to log in again');
}
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $exception) {
$this->error($exception->getMessage());
}
}

/**
 * Submit verification code and complete login
 */
public function submitCode()
{
    try {
        $data = $this->_vali([
            'code.require'         => 'code cannot be empty!',
            'telegram_id.require'  => 'Account ID cannot be empty!'
        ]);
        $session_file = syspath('madeline')."\session_{$data['telegram_id']}.madeline";
        $this->MadelineProto = new API($session_file);
        // Complete login using verification code
        $this->MadelineProto->completePhoneLogin($data['code']);
        $this->success('Authorization successful, login completed!');
    } catch (HttpResponseException $exception) {
        throw $exception;
    } catch (\Exception $exception) {
        $this->error($exception->getMessage());
    }
}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant