Пример #1
0
        private void btnCerrarSession_Clicked(object sender, EventArgs e)
        {
            userDataBase = new UserDataBase();
            var user_exist = userDataBase.GetMembers().ToList();
            var idx        = user_exist[0].id;
            var tok        = user_exist[0].token;

            var userW = new User();

            userW.id_cliente = 0;

            userW.name           = "";
            userW.nombre         = "";
            userW.password       = "";
            userW.username       = "";
            userW.remember_token = "";
            userW.google_id      = "";
            userW.email          = "";
            userW.token          = tok;
            userW.status         = 0;
            userDataBase.DeleteMember(idx);
            userDataBase.AddMember(userW);



            Application.Current.MainPage = new NavigationPage(new Login());
        }
Пример #2
0
        private async void btnRegistDone_Clicked(object sender, EventArgs e)
        {
            Cator.IsRunning         = true;
            Cator.IsVisible         = true;
            btnRegistDone.IsEnabled = false;
            var user = User_.Text;
            var pass = Pass_.Text;

            if (string.IsNullOrEmpty(User_.Text) || string.IsNullOrWhiteSpace(User_.Text))
            {
                User_.Focus();
            }
            else if (string.IsNullOrEmpty(Pass_.Text) || string.IsNullOrWhiteSpace(Pass_.Text))
            {
                Pass_.Focus();
            }

            else
            {
                HttpClient client = new HttpClient();

                UserDb = new UserDataBase();
                var userW       = new User();
                var user_exista = UserDb.GetMembers().ToList();
                var token       = user_exista[0].token;


                var value_check = new Dictionary <string, string>
                {
                    { "email", user },
                    { "pass", pass },
                    { "token", token }
                };

                var contentx = new FormUrlEncodedContent(value_check);

                try
                {
                    var response = await client.PostAsync("http://www.washdryapp.com/app/public/solicitud/login_cliente", contentx);


                    HttpContent content = response.Content;

                    var json = await content.ReadAsStringAsync();

                    if (json == "[{\"nombre\":\"fail\"}]")
                    {
                        await DisplayAlert("Error", "su nombre o contraseña son invalidos", "ok");
                    }
                    else
                    {
                        var json_ = JsonConvert.DeserializeObject <List <User> >(json);



                        var user_x = new User();
                        //var userDataBase = new UserDataBase();
                        UserDb = new UserDataBase();
                        var tk = UserDb.GetMembers().ToList().FirstOrDefault();

                        user_x.email          = json_[0].email;
                        user_x.google_id      = json_[0].google_id;
                        user_x.name           = json_[0].name;
                        user_x.nombre         = json_[0].nombre;
                        user_x.password       = "";
                        user_x.status         = 0;
                        user_x.remember_token = "";
                        user_x.id             = json_[0].id;
                        user_x.id_cliente     = json_[0].id;
                        user_x.username       = json_[0].username;
                        user_x.remember_token = "";//username id
                        user_x.token          = tk.token;


                        UserDb.AddMember(user_x);
                        UserDb.DeleteMember(0);


                        Application.Current.MainPage = new MainPage();
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("", "" + ex.ToString(), "");
                }
            }


            Cator.IsRunning         = false;
            Cator.IsVisible         = false;
            btnRegistDone.IsEnabled = true;
        }
Пример #3
0
        public async void  Access_Login(object sender, EventArgs e)
        {
            Cator.IsVisible    = true; Cator.IsRunning = true;
            Username.IsVisible = false; Pass.IsVisible = false;
            SubmitButton.Text  = "Procesando";

            //paso 1 confirmar contraseña


            HttpClient client = new HttpClient();

            var username = Username.Text;
            var pass     = Pass.Text;

            var values = new Dictionary <string, string>
            {
                { "username", "kiko" },
                { "pass", "12345678" }
            };

            var content = new FormUrlEncodedContent(values);

            var response = await client.PostAsync("https://trustfundapp.herokuapp.com/m/confirm-pass",
                                                  content);



            //if contraseña true

            //paso 2 solicitar token a trustfund

            // paso 3

            switch (response.StatusCode)
            {
            case (System.Net.HttpStatusCode.OK):



                string xjson = await response.Content.ReadAsStringAsync();



                var json_ = JsonConvert.DeserializeObject <ResponceTrustPass>(xjson);


                try {
                    user         = new User();
                    userDataBase = new UserDataBase();

                    //userDataBase.DropTbMember();
                    user.username = json_.responce.user_info.username;
                    user.mail     = json_.responce.user_info.mail;
                    user.tok      = json_.responce.token;
                    user.id       = json_.responce.user_info.id;

                    userDataBase.AddMember(user);

                    await DisplayAlert("error", "yeah", "ok");
                }
                catch (Exception err) {
                    var ersr = err;

                    await DisplayAlert("error", "yeah" + err.ToString(), "ok");
                }

                Application.Current.MainPage = new NavigationPage(new MainPage());

                break;


            case (System.Net.HttpStatusCode.Forbidden):
                //contraseña incorrecta

                Cator.IsVisible    = false; Cator.IsRunning = false;
                Username.IsVisible = true; Pass.IsVisible = true;
                Pass.Focus();

                SubmitButton.Text = "Ingresar";

                break;

            case (System.Net.HttpStatusCode.MethodNotAllowed):
                //usuario invalido

                Cator.IsVisible    = false; Cator.IsRunning = false;
                Username.IsVisible = true; Pass.IsVisible = true;
                Pass.Focus();

                SubmitButton.Text = "Ingresar";

                break;
            }
        }
Пример #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;
            Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, savedInstanceState);
            Rg.Plugins.Popup.Popup.Init(this, savedInstanceState);
            base.OnCreate(savedInstanceState);

            global::Xamarin.Forms.Forms.SetFlags(new[] { "CollectionView_Experimental", "Shell_Experimental" });
            Xamarin.FormsMaps.Init(this, savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

            LoadApplication(new App());

            //CreateNotificationChannel();

            IsPlayServicesAvailable();
            Log.Debug(TAG, "InstanceID token: " + FirebaseInstanceId.Instance.Token);
            var token = FirebaseInstanceId.Instance.Token;

            //CONSULTAR BD
            userdb = new UserDataBase();
            var userW       = new User();
            var user_exista = userdb.GetMembers().ToList();
            var user_exist  = userdb.GetMembers();
            int RowCount    = 0;
            int usercount   = user_exist.Count();

            RowCount = Convert.ToInt32(usercount);
            if (RowCount > 1)
            {
                userdb.DeleteMembers();
                userW.token  = token;
                userW.status = 0;
                userdb.AddMember(userW);
            }
            else if (RowCount == 1)
            {
                userdb.UpdateMemberToken(user_exista[0].id, token);

                /*if (token != user_exista[0].token)
                 * {
                 *
                 * }*/
            }
            else
            {
                if (token == null || token == "")
                {
                    FinishAffinity();
                }
                userW.id_cliente = 0;

                userW.name           = "";
                userW.nombre         = "";
                userW.password       = "";
                userW.username       = "";
                userW.remember_token = "";
                userW.google_id      = "";
                userW.email          = "";
                userW.token          = token;
                userW.status         = 0;
                userdb.AddMember(userW);
            }
        }