Exemple #1
0
 private void Login()
 {
     if (EmailTxt.ToString() == "*****@*****.**" && PasswordTxt.ToString() == "1234")
     {
         Application.Current.MainPage.DisplayAlert("Correcto", "Logrado", "ok");
     }
     else
     {
         Application.Current.MainPage.DisplayAlert("Incorrecto", "No fue logrado", "ok");
     }
 }
Exemple #2
0
 private void login()
 {
     if (EmailTxt.ToString() == "*****@*****.**" && PasswordTxt.ToString() == "123456")
     {
         Application.Current.MainPage.DisplayAlert("Correcto", "Bienvenido", "ok");
     }
     else
     {
         Application.Current.MainPage.DisplayAlert("Incorrecto", "Usario y/o contraseña no valido", "ok");
     }
 }
Exemple #3
0
        public async void LoginMethod()
        {
            if (string.IsNullOrEmpty(this.email))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an email.",
                    "Accept");

                return;
            }
            if (string.IsNullOrEmpty(this.password))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter a password.",
                    "Accept");

                return;
            }

            string WebAPIkey = "AIzaSyDvh8bOMOG0-bRlSI2cmbbpjHW21Bmzgwg";


            var authProvider = new FirebaseAuthProvider(new FirebaseConfig(WebAPIkey));

            try
            {
                var auth = await authProvider.SignInWithEmailAndPasswordAsync(EmailTxt.ToString(), PasswordTxt.ToString());

                var content = await auth.GetFreshAuthAsync();

                var serializedcontnet = JsonConvert.SerializeObject(content);

                Preferences.Set("MyFirebaseRefreshToken", serializedcontnet);
                await Shell.Current.GoToAsync($"//ProfilePage");
            }
            catch (Exception ex)
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Invalid useremail or password", "OK");
            }

            this.IsVisibleTxt = true;
            this.IsRunningTxt = true;
            this.IsEnabledTxt = false;

            await Task.Delay(20);


            this.IsRunningTxt = false;
            this.IsVisibleTxt = false;
            this.IsEnabledTxt = true;
        }
        private async void RegisterMethod()
        {
            if (string.IsNullOrEmpty(this.email))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an email.",
                    "Accept");

                return;
            }

            if (string.IsNullOrEmpty(this.password))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter a password.",
                    "Accept");

                return;
            }

            string WebAPIkey = "AIzaSyBJ7GurFSPSpXxhwoJ93KU68Ia6rXIMZb4";

            try
            {
                var authProvider = new FirebaseAuthProvider(new FirebaseConfig(WebAPIkey));
                var auth         = await authProvider.CreateUserWithEmailAndPasswordAsync(EmailTxt.ToString(), PasswordTxt.ToString());

                string gettoken = auth.FirebaseToken;

                await Application.Current.MainPage.DisplayAlert("Successfully", "Welcome " + name.ToString() + " to your app", "Ok");

                this.IsRunningTxt = false;
                this.IsVisibleTxt = false;
                this.IsEnabledTxt = true;
                await Application.Current.MainPage.Navigation.PushAsync(new LoginPage());
            }
            catch (Exception ex)
            {
            }
        }
Exemple #5
0
        public async void LoginMethod()
        {
            if (string.IsNullOrEmpty(this.email))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an email.",
                    "Accept");

                return;
            }
            if (string.IsNullOrEmpty(this.password))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter a password.",
                    "Accept");

                return;
            }

            string WebAPIkey = "AIzaSyBJ7GurFSPSpXxhwoJ93KU68Ia6rXIMZb4";


            var authProvider = new FirebaseAuthProvider(new FirebaseConfig(WebAPIkey));

            try
            {
                var auth = await authProvider.SignInWithEmailAndPasswordAsync(EmailTxt.ToString(), PasswordTxt.ToString());

                var content = await auth.GetFreshAuthAsync();

                var serializedcontnet = JsonConvert.SerializeObject(content);

                Preferences.Set("MyFirebaseRefreshToken", serializedcontnet);

                //Puede navegar al tener autorizacion
                await Application.Current.MainPage.Navigation.PushAsync(new ContainerTabbedPags());

                this.IsRunningTxt = false;
                this.IsVisibleTxt = false;
                this.IsEnabledTxt = true;
            }
            catch (Exception ex)
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Invalid useremail or password", "OK");

                this.IsRunningTxt = false;
                this.IsVisibleTxt = false;
                this.IsEnabledTxt = true;
            }
        }
        private async void OnRegisterClicked()
        {
            if (string.IsNullOrEmpty(this.email))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an email.",
                    "Accept");

                return;
            }

            if (string.IsNullOrEmpty(this.password))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter a password.",
                    "Accept");

                return;
            }

            string WebAPIkey = "AIzaSyDvh8bOMOG0-bRlSI2cmbbpjHW21Bmzgwg";

            try
            {
                var authProvider = new FirebaseAuthProvider(new FirebaseConfig(WebAPIkey));
                var auth         = await authProvider.CreateUserWithEmailAndPasswordAsync(EmailTxt.ToString(), PasswordTxt.ToString());

                string gettoken = auth.FirebaseToken;

                await Shell.Current.GoToAsync($"//{nameof(LoginPage)}");
            }
            catch (Exception ex)
            {
                await App.Current.MainPage.DisplayAlert("Alert", ex.Message, "OK");
            }

            /*
             * if (string.IsNullOrEmpty(this.name))
             * {
             *  await Application.Current.MainPage.DisplayAlert(
             *      "Error",
             *      "You must enter a name.",
             *      "Accept");
             *  return;
             * }
             * if (string.IsNullOrEmpty(this.age))
             * {
             *  await Application.Current.MainPage.DisplayAlert(
             *      "Error",
             *      "You must enter an age.",
             *      "Accept");
             *  return;
             * }
             * this.IsVisibleTxt = true;
             * this.IsRunningTxt = true;
             * this.IsEnabledTxt = false;
             * var user = new UserModel
             * {
             *  EmailField = email,
             *  PasswordField = password,
             *  NamesField = name,
             *  AgeField = age,
             *  Creation_Date = DateTime.Now,
             * };
             * await App.Database.SaveUserModelAsync(user);
             * await Application.Current.MainPage.DisplayAlert("Successfully", "Welcome " + name.ToString() + " to your app", "Ok");
             * this.IsRunningTxt = false;
             * this.IsVisibleTxt = false;
             * this.IsEnabledTxt = true;
             * await Application.Current.MainPage.Navigation.PushAsync(new LoginPage());
             */
        }