示例#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;
                }
            }
        }
示例#2
0
        private async void Logout_test(object sender, RoutedEventArgs e)
        {
            MessageDialog popup = new MessageDialog("Do you want to log out from this account?", "Logout");

            popup.Commands.Add(new UICommand("Logout")
            {
                Id = 0
            });
            popup.Commands.Add(new UICommand("Cancel")
            {
                Id = 1
            });
            popup.DefaultCommandIndex = 0;
            popup.CancelCommandIndex  = 1;
            var result = await popup.ShowAsync();

            if ((int)result.Id == 0)
            {
                //remove user credentials
                var getuserpass = new Logincredentials().getcredentialfromlocker(1);
                getuserpass.RetrievePassword();
                var vault = new Windows.Security.Credentials.PasswordVault();
                vault.Remove(new Windows.Security.Credentials.PasswordCredential(getuserpass.Resource, getuserpass.UserName, getuserpass.Password));
                //navigate back to the loginpage
                f.Navigate(typeof(LoginPage));
                Window.Current.Content = f;
                Window.Current.Activate();
            }
        }
示例#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;
                }
            }
        }