コード例 #1
0
        private async void OnSubmitButtonClicked(object sender, EventArgs e)
        {
            submitButton.Clicked -= OnSubmitButtonClicked;

            try
            {
                var result = await WalletApiSingleton.Instance.AuthAsync(ViewModel.Email, ViewModel.Password);

                string pk = result.EncodedPrivateKey.TrimEnd('\0');
                if (string.IsNullOrEmpty(result.EncodedPrivateKey))
                {
                    var r = await WalletApiSingleton.Instance.PostEncodedPrivateKey(ViewModel.Password);

                    pk = r.EncodedPrivateKey;
                }
                var decodedPk = AESHelper.DecryptHex128(pk, ViewModel.Password).TrimEnd('\0');
                LocalKeyAccessSingleton.Instance.SavePrivateKey(decodedPk);
                LocalKeyAccessSingleton.Instance.AddOrUpdateEmailKeyPair(ViewModel.Email, result.EncodedPrivateKey);

                if (!string.IsNullOrEmpty(result.EncodedPrivateKey))
                {
                }
                await Navigation.PushAsync(new MainTabbedPage(true));
            }
            catch (InvalidUsernameOrPasswordException ex)
            {
                await DisplayAlert("", "Invalid username or password", "OK");

                passwordEntry.Focus();
            }
            finally
            {
                submitButton.Clicked += OnSubmitButtonClicked;
            }
        }