Exemplo n.º 1
0
        private async Task AutoLogin()
        {
            var autologin = new Logincredentials().getcredentialfromlocker(1);

            if (autologin != null)
            {
                autologin.RetrievePassword();

                //check if user changed the password
                Logincredentials login = new Logincredentials();
                bool             canweusethepassword = await login.logincredential(autologin.UserName, autologin.Password, 1);

                switch (canweusethepassword)
                {
                case true:
                    await DataProvider.GrabUserDatatoOffline(1);

                    _navigationService.NavigateTo("HomePage");
                    _Fnavigationservice.NavigateTo("VirDir");
                    break;

                case false: break;
                }
            }
        }
Exemplo n.º 2
0
        /*  private async void result(object sender, RoutedEventArgs e)
         * {
         *    try
         *    {
         *        var getlogincredentials = new GrabUserList().getcredentialfromlocker();
         *        getlogincredentials.RetrievePassword();
         *        var url = new Uri("http://myanimelist.net/api/account/verify_credentials.xml");
         *        //string storeusercredential_myanimelist = "mall";
         *        GrabUserList nn = new GrabUserList();
         *
         *        var clientHeader = new HttpBaseProtocolFilter();
         *        clientHeader.ServerCredential = new PasswordCredential(getlogincredentials.Resource,getlogincredentials.UserName, getlogincredentials.Password);
         *        clientHeader.AllowUI = false;
         *        using (var client = new HttpClient(clientHeader))
         *        {
         *            HttpResponseMessage response = await client.GetAsync(url);
         *            response.EnsureSuccessStatusCode();
         *            string getrespond = await response.Content.ReadAsStringAsync();
         *            //store password
         *            //var vault = new PasswordVault();
         *            //var cred = clientHeader.ServerCredential;
         *            //vault.Add(cred);
         *            test.Content = getrespond;
         *        }
         #region oldcode_but_works
         *        // old one, but works
         *        // problem : can't disable basic authentication pop-up when failed to login.
         *        /*using (HttpClient client = new HttpClient()) {
         *            //client.DefaultRequestHeaders.Accept.TryParseAdd("application/json");
         *            client.DefaultRequestHeaders.Authorization = new Windows.Web.Http.Headers.HttpCredentialsHeaderValue("basic",Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Format("{0}:{1}", username, password))));
         *            using (HttpResponseMessage response = await client.GetAsync(url))
         *            {
         *                response.EnsureSuccessStatusCode();
         *                string getresponse = await response.Content.ReadAsStringAsync();
         *                test.Content = getresponse;
         *            }
         *          }
         *
         #endregion
         *    }
         *    catch (Exception ex) {
         *        test.Content = "Maa-kun confused. She can't use your username / password to access it :(";
         *        }
         * }*/

        private async void SignIn_Click(ContentDialog sender, ContentDialogButtonClickEventArgs e)
        {
            Logincredentials login  = new Logincredentials();
            bool             verify = await login.logincredential(usrnm.Text, psswd.Password, 1);

            switch (verify)
            {
            case true:
                await DataProvider.GrabUserDatatoOffline(1);

                Navigate();
                break;

            case false: break;
            }
        }
Exemplo n.º 3
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter is string && e.Parameter.ToString() == "usr_ava")
            {
                var autologin = new Logincredentials().getcredentialfromlocker(1);
                autologin.RetrievePassword();
                Logincredentials login = new Logincredentials();
                bool             canweusethepassword = await login.logincredential(autologin.UserName, autologin.Password, 1);

                switch (canweusethepassword)
                {
                case true:
                    await DataProvider.GrabUserDatatoOffline(1);

                    Navigate();
                    break;

                case false: break;
                }
            }
        }