Example #1
0
        public async void SignInClicked(object sender, EventArgs e)
        {
            try
            {
                if (!String.IsNullOrEmpty(txt_Email.Text) & !String.IsNullOrEmpty(txt_Password.Text))
                {
                    //var test = GetUser(txt_Email.Text);
                    //if (test.Result.userPassword == txt_Password.Text)
                    //{


                    // this is one option.
                    if (await AuthEmail(txt_Email.Text, txt_Password.Text) == true)
                    {
                        Settings.authToken = token.FirebaseToken;

                        //var test = GetUser(txt_Email.Text);
                        //Settings.UserKey = test.Result.userNo;
                        Settings.email    = txt_Email.Text;
                        Settings.password = txt_Password.Text;

                        var main = new MainPage1();
                        await Navigation.PushAsync(main, false);
                    }
                    else
                    {
                        await DisplayAlert("Login", "Email address or password are incorrect, please try again.", "Ok");
                    }
                }
                else
                {
                    await DisplayAlert("Login", "Email address or password are not valid, please try again.", "Ok");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Login", "Email address or password are incorrect, please try again", "Ok");
            }
        }
Example #2
0
        private async void RegisterClicked(object sender, EventArgs e)
        {
            try
            {
                //var sqliteFilename = "olive.db3";
                //string dbPath = DependencyService.Get<IDbFilePath>().GetLocalFilePath();
                //dbPath = Path.Combine(dbPath, sqliteFilename);

                if (!String.IsNullOrEmpty(txt_Email.Text) & !String.IsNullOrEmpty(txt_Password.Text) & !String.IsNullOrEmpty(txt_FirstName.Text)
                    & !String.IsNullOrEmpty(txt_LastName.Text) & !String.IsNullOrEmpty(txt_Address1.Text) & !String.IsNullOrEmpty(txt_Town.Text)
                    & !String.IsNullOrEmpty(txt_Telephone.Text) & txt_Password.Text == txt_PasswordConfirm.Text)
                {
                    if (await AuthSignUpEmail(txt_Email.Text, txt_Password.Text) == true)
                    {
                        await CreateUser(txt_FirstName.Text, txt_LastName.Text, txt_Email.Text, txt_Password.Text, txt_Telephone.Text, txt_Address1.Text, txt_Address2.Text, txt_Town.Text, txt_County.Text, txt_PostCode.Text, DateTime.Today);

                        Settings.email    = txt_Email.Text;
                        Settings.password = txt_Password.Text;
                        var main = new MainPage1();
                        await Navigation.PushAsync(main, false);
                    }
                    else
                    {
                        await DisplayAlert("Register", "An error occurred, please try again later", "Ok");
                    }
                }
                else
                {
                    await DisplayAlert("Register", "Please ensure all required fields are completed and try again", "Ok");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", ex.ToString(), "OK");
            }
        }