Exemple #1
0
        private async void Login()
        {
            RestService.Authenticate(this.Entity as User,
                                     //onSuccess
                                     (token) => {
                Application.Current.MainPage = new NavigationPage(new MainPage());
            },

                                     //onFailure
                                     (e) => _iPopupsService.DisplayAlert("erro", e, "OK")
                                     );
        }
Exemple #2
0
        private async void ButtonSignIn_Click(object sender, EventArgs e)
        {
            string email    = editTextEmail.Text;
            string password = editTextPassword.Text;

            buttonSignIn.Enabled = false;
            User user = await _restService.Authenticate(new User { Email = email, Password = password }, false);

            if (user != null)
            {
                user.Password = password;
                AppPreferenceUser.SetUser(user);
                var intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
                Finish();
            }
            else
            {
                buttonSignIn.Enabled = true;
                Toast.MakeText(this, Resource.String.incorrect_pass_or_email, ToastLength.Long).Show();
            }
        }
Exemple #3
0
        private async void ButtonCreateAccount_Click(object sender, EventArgs e)
        {
            string email    = editTextEmail.Text;
            string password = editTextPassword.Text;

            if (!IsValidEmail(email))
            {
                Toast.MakeText(this, Resource.String.invalid_email_format, ToastLength.Long).Show();
                return;
            }
            if (password.Length < 8)
            {
                Toast.MakeText(this, Resource.String.password_tooshort, ToastLength.Long).Show();
                return;
            }
            if (password != editTextConfirmPassword.Text)
            {
                Toast.MakeText(this, Resource.String.passwords_dont_match, ToastLength.Long).Show();
                return;
            }

            buttonCreateAccount.Enabled = false;
            User user = await _restServiceRegister.Authenticate(new User { Email = email, Password = password }, true);

            if (user != null)
            {
                user.Password = password;
                AppPreferenceUser.SetUser(user);
                var intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
                Finish();
            }
            else
            {
                buttonCreateAccount.Enabled = true;
                Toast.MakeText(this, Resource.String.incorrect_pass_or_email, ToastLength.Long).Show();
            }
        }