示例#1
0
        private void OnRegistrationClicked(object sender, System.EventArgs e)
        {
            var page = new RegistrationPage(false);

            Navigation.PushAsync(page, true);
        }
示例#2
0
        private async void LoginClicked(object sender, EventArgs e)
        {
            if (IsValid())
            {
                Unfocus();

                if (!App.Locator.FriendlyService.IsFundWorking)
                {
                    ShowErrorMessage(AppResources.RegistrationFundNotWorking);
                    return;
                }

                App.ShowLoading(true);

                try
                {
                    Profile.KeyData kd;

                    if (!String.IsNullOrWhiteSpace(entrySecretKey.Text))
                    {
                        kd = Profile.GenerateKeyPairFromSeed(entrySecretKey.Text);
                    }
                    else
                    {
                        //Generate private key
                        kd = Profile.GenerateKeyPairFromMnemonic(entryMnemonic.Text);
                    }

                    App.Locator.Profile.KeyPair = kd.KeyPair;

                    var result = await App.Locator.IdentityServiceClient.GetUser(kd.KeyPair.Address, null);

                    if (result != null)
                    {
                        App.Locator.Profile.SetCredentials(result.UserDetails.PaketUser, kd.KeyPair.SecretSeed, kd.MnemonicString);

                        var infosResult = await App.Locator.IdentityServiceClient.UserInfos();

                        if (infosResult != null && !String.IsNullOrWhiteSpace(infosResult.UserDetails.PhoneNumber))
                        {
                            Application.Current.Properties[Constants.STORED_PHONE] = infosResult.UserDetails.PhoneNumber;

                            CheckActivation();
                        }
                        else
                        {
                            var page = new RegistrationPage(true, result.UserDetails);

                            await Navigation.PushAsync(page, true);

                            App.ShowLoading(false);
                        }
                    }
                    else
                    {
                        App.Locator.Profile.SetCredentials(kd.KeyPair.SecretSeed, kd.MnemonicString);

                        var page = new RegistrationPage(true);

                        await Navigation.PushAsync(page, true);

                        App.ShowLoading(false);
                    }
                }
                catch (Exception ex)
                {
                    App.ShowLoading(false);

                    App.Locator.Profile.KeyPair = null;

                    ShowErrorMessage(ex is OutOfMemoryException ? "Secret key is invalid" : ex.Message);
                }
            }
        }