From 2e84061b4d10c6c8783b450b31d41d1ce39bb7ae Mon Sep 17 00:00:00 2001 From: Wizou <11647984+wiz0u@users.noreply.github.com> Date: Thu, 13 Oct 2022 10:07:46 +0200 Subject: [PATCH] Login: warning on phone_number mismatch --- README.md | 4 ++-- src/Client.cs | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b4ad071..e25529a 100644 --- a/README.md +++ b/README.md @@ -92,9 +92,9 @@ Since version 3.0.0, a new approach to login/configuration has been added. Some ```csharp WTelegram.Client client = new WTelegram.Client(YOUR_API_ID, "YOUR_API_HASH"); -await DoLogin("+12025550156"); +await DoLogin("+12025550156"); // user's phone_number -async Task DoLogin(string loginInfo) // add this method to your code +async Task DoLogin(string loginInfo) // (add this method to your code) { while (client.User == null) switch (await client.Login(loginInfo)) // returns which config info is needed to continue login diff --git a/src/Client.cs b/src/Client.cs index da3ee18..2a06512 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -1119,7 +1119,10 @@ namespace WTelegram authorization = await this.Auth_SignUp(phone_number, sentCode.phone_code_hash, first_name, last_name); } #pragma warning restore CS0618 - return LoginAlreadyDone(authorization); + LoginAlreadyDone(authorization); + if (User.phone != string.Concat(phone_number.Where(char.IsDigit))) + Helpers.Log(3, $"Mismatched phone_number (+{User.phone} != {phone_number}). Fix this to avoid verification code each time"); + return User; } /// [Not recommended] You can use this if you have already obtained a login authorization manually