/// <inheritdoc /> public async Task<TUser> SignUpAsync(string phoneNumber, ISentCode sentCode, string code, string firstName, string lastName, CancellationToken cancellationToken = default(CancellationToken)) { Guard.That(phoneNumber, nameof(phoneNumber)).IsNotNullOrWhiteSpace(); Guard.That(code, nameof(code)).IsNotNullOrWhiteSpace(); Guard.That(firstName, nameof(firstName)).IsNotNullOrWhiteSpace(); Guard.That(lastName, nameof(lastName)).IsNotNullOrWhiteSpace(); var request = new RequestSignUp { PhoneNumber = phoneNumber, PhoneCode = code, PhoneCodeHash = sentCode.PhoneCodeHash, FirstName = firstName, LastName = lastName }; var result = (TAuthorization)await RequestSender.SendRequestAsync(request, cancellationToken).ConfigureAwait(false); var user = result.User.Is<TUser>(); await OnUserAuthenticated(user).ConfigureAwait(false); return user; }
public async Task <string> HandleAsync(Query query) { string hashedPhoneId = HashHelper.GetHash(query.PhoneNumber); IClientApi client = await _telegramService.BuildAsync(hashedPhoneId).ConfigureAwait(false); ISentCode result = await TelegramRequest.HandleAsync(() => { return(client.AuthService.SendCodeAsync(query.PhoneNumber)); }).ConfigureAwait(false); return(result.PhoneCodeHash); }
private void btnTelegramLogin_Click(object sender, EventArgs e) { try { hash = Task.Run(() => Telegram.clientApi.AuthService.SendCodeAsync(txtPhoneNumber.Text)).Result; Properties.Settings.Default.PhoneNumber = txtPhoneNumber.Text; Properties.Settings.Default.Save(); txtVerificationCode.Enabled = true; btnSendVerification.Enabled = true; txtPhoneNumber.Enabled = false; btnTelegramLogin.Enabled = false; } catch (AggregateException ex) { MessageBox.Show(ex.InnerExceptions[0].Message, "Telecord"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Telecord"); } }