Esempio n. 1
0
        private async void Update()
        {
            var response = await LegacyService.GetPasswordAsync();

            if (response.IsSucceeded)
            {
            }
        }
Esempio n. 2
0
        private async void SendExecute()
        {
            IsLoading = true;

            var passwordResponse = await LegacyService.GetPasswordAsync();

            if (passwordResponse.IsSucceeded)
            {
                if (passwordResponse.Result is TLAccountPassword password)
                {
                    var currentSalt = password.CurrentSalt;
                    var hash        = TLUtils.Combine(currentSalt, Encoding.UTF8.GetBytes(_password), currentSalt);

                    var input  = CryptographicBuffer.CreateFromByteArray(hash);
                    var hasher = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256);
                    var hashed = hasher.HashData(input);
                    CryptographicBuffer.CopyToByteArray(hashed, out byte[] data);

                    var response = await LegacyService.GetTmpPasswordAsync(data, 60 * 30);

                    if (response.IsSucceeded)
                    {
                        ApplicationSettings.Current.TmpPassword = response.Result;
                        //NavigationService.NavigateToPaymentFormStep5(_message, _paymentForm, _info, _requestedInfo, _shipping, null, null, true);
                    }
                    else if (response.Error != null)
                    {
                        IsLoading = false;

                        if (response.Error.TypeEquals(TLErrorType.PASSWORD_HASH_INVALID))
                        {
                            Password = string.Empty;
                            RaisePropertyChanged(response.Error.ErrorMessage);
                        }
                        else
                        {
                        }
                    }
                }
                else
                {
                }
            }
            else if (passwordResponse.Error != null)
            {
                IsLoading = false;
            }
        }
Esempio n. 3
0
        private async void SendExecute()
        {
            if (_sentCode == null)
            {
                //...
                return;
            }

            if (string.IsNullOrEmpty(_phoneCode))
            {
                RaisePropertyChanged("SENT_CODE_INVALID");
                return;
            }

            var phoneNumber   = _phoneNumber;
            var phoneCodeHash = _sentCode.PhoneCodeHash;

            IsLoading = true;

            var response = await LegacyService.ChangePhoneAsync(phoneNumber, phoneCodeHash, _phoneCode);

            if (response.IsSucceeded)
            {
                while (NavigationService.Frame.BackStackDepth > 1)
                {
                    NavigationService.Frame.BackStack.RemoveAt(1);
                }

                NavigationService.GoBack();
            }
            else
            {
                IsLoading = false;

                if (response.Error.TypeEquals(TLErrorType.PHONE_NUMBER_UNOCCUPIED))
                {
                    //var signup = await ProtoService.SignUpAsync(phoneNumber, phoneCodeHash, PhoneCode, "Paolo", "Veneziani");
                    //if (signup.IsSucceeded)
                    //{
                    //    ProtoService.SetInitState();
                    //    ProtoService.CurrentUserId = signup.Value.User.Id;
                    //    SettingsHelper.IsAuthorized = true;
                    //    SettingsHelper.UserId = signup.Value.User.Id;
                    //}

                    //this._callTimer.Stop();
                    //this.StateService.ClearNavigationStack = true;
                    //this.NavigationService.UriFor<SignUpViewModel>().Navigate();
                    var state = new SignUpPage.NavigationParameters
                    {
                        PhoneNumber = _phoneNumber,
                        PhoneCode   = _phoneCode,
                        //Result = _sentCode,
                    };

                    NavigationService.Navigate(typeof(SignUpPage), state);
                }
                else if (response.Error.TypeEquals(TLErrorType.PHONE_CODE_INVALID))
                {
                    //await new MessageDialog(Resources.PhoneCodeInvalidString, Resources.Error).ShowAsync();
                }
                else if (response.Error.TypeEquals(TLErrorType.PHONE_CODE_EMPTY))
                {
                    //await new MessageDialog(Resources.PhoneCodeEmpty, Resources.Error).ShowAsync();
                }
                else if (response.Error.TypeEquals(TLErrorType.PHONE_CODE_EXPIRED))
                {
                    //await new MessageDialog(Resources.PhoneCodeExpiredString, Resources.Error).ShowAsync();
                }
                else if (response.Error.TypeEquals(TLErrorType.SESSION_PASSWORD_NEEDED))
                {
                    //this.IsWorking = true;
                    var password = await LegacyService.GetPasswordAsync();

                    if (password.IsSucceeded && password.Result is TLAccountPassword)
                    {
                        var state = new SignInPasswordPage.NavigationParameters
                        {
                            PhoneNumber = _phoneNumber,
                            PhoneCode   = _phoneCode,
                            //Result = _sentCode,
                            //Password = password.Result as TLAccountPassword
                        };

                        NavigationService.Navigate(typeof(SignInPasswordPage), state);
                    }
                    else
                    {
                        Execute.ShowDebugMessage("account.getPassword error " + password.Error);
                    }
                }
                else if (response.Error.CodeEquals(TLErrorCode.FLOOD))
                {
                    //await new MessageDialog($"{Resources.FloodWaitString}\r\n\r\n({error.Message})", Resources.Error).ShowAsync();
                }

                Execute.ShowDebugMessage("account.signIn error " + response.Error);
            }
        }