Esempio n. 1
0
        /// <summary>
        /// Method invoked when the user clicks on Cambia utente.
        /// Unregister the background task and removes all user data in order to allow
        /// another user to use the app.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void HyperlinkButton_Click_2(object sender, RoutedEventArgs e)
        {
            try
            {
                await Singleton <ClientExtensions> .Instance.Logout();

                ShellPage.Current.SessionTimeout.Stop();

                SecurityExtensions.RemoveCredentials();

                Singleton <ClientExtensions> .Instance.AccountDetails = new Profile();

                NavigationService.Navigate(typeof(LockedPage));

                ShellPage.Current.Loader.IsLoading = true;
            }
            catch (Exception ex) { ShellPage.Current.HandleExceptionNotification(ex); }
        }
Esempio n. 2
0
        /// <summary>
        /// Method invoked when the user clicks on Change user.
        /// Unregister the background task and removes all user data in order to allow
        /// another user to use the app.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void HyperlinkButton_Click_2(object sender, RoutedEventArgs e)
        {
            try
            {
                // TODO: Fix this monstrosity
                Singleton <ClientExtensions> .Instance.DisconnectUser();

                SecurityExtensions.RemoveCredentials();

                NavigationService.Navigate(typeof(LockedPage));

                ShellPage.Current.Loader.IsLoading = true;
            }
            catch (Exception ex)
            {
                Analytics.TrackEvent(ex.Message, new Dictionary <string, string> {
                    { "exception", ex.ToString() }
                });
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Method invoked when the user clicks on Accedi.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            StatusProgressBar.Opacity     = 1;
            UsernameTextBox.IsEnabled     = false;
            PasswordPasswordBox.IsEnabled = false;
            LoginButton.IsEnabled         = false;

            try
            {
                if (ApplicationData.Current.LocalSettings.Values.ContainsKey("HelloAuthenticationEnabled"))
                {
                    switch (await UserConsentVerifier.RequestVerificationAsync(SecurityExtensions.MESSAGE))
                    {
                    case UserConsentVerificationResult.Verified:
                    {
                        await Singleton <ClientExtensions> .Instance.Authenticate(UsernameTextBox.Text, PasswordPasswordBox.Password);

                        break;
                    }

                    case UserConsentVerificationResult.DeviceNotPresent:
                    {
                        SecurityExtensions.RemoveCredentials();
                        await new MessageDialog("L'autenticazione sicura tramite Windows Hello è stata disabilitata a causa della mancanza di opzioni di accesso valide. Per poter riabilitare questa funzione è necessario specificare un metodo di autenticazione valido (PIN, impronta digitale o scansione dell'iride) nelle impostazioni di Windows.\n\nPer motivi di sicurezza le credenziali del tuo account iliad dovranno essere inserite manualmente per questa sessione.", "Attenzione").ShowAsync();
                        break;
                    }

                    default:
                    {
                        Application.Current.Exit();
                        break;
                    }
                    }
                }
                else
                {
                    await Singleton <ClientExtensions> .Instance.Authenticate(UsernameTextBox.Text, PasswordPasswordBox.Password);
                }

                SessionTimeout.Tick += (s, o) =>
                {
                    Singleton <ClientExtensions> .Instance.Authenticate(UsernameTextBox.Text, PasswordPasswordBox.Password); // Never await this method!
                };

                SecurityExtensions.AddCredentials(UsernameTextBox.Text, PasswordPasswordBox.Password);

                AppNotification.IsOpen = false;

                NavigationService.Navigate(typeof(MainPage), new EntranceNavigationTransitionInfo());
                navigationView.SelectedItem = navigationView.MenuItems[0];
                IsBackEnabled = false;
                NavigationService.Frame.BackStack.Clear();

                Loader.IsLoading = false;

                SessionTimeout.Start();
            }
            catch (Exception ex)
            {
                HandleExceptionNotification(ex);
            }

            _avoidCheck = false;

            UsernameTextBox.IsEnabled     = true;
            PasswordPasswordBox.IsEnabled = true;
            LoginButton.IsEnabled         = true;
            StatusProgressBar.Opacity     = 0;
        }