private void RedirectPageForLoggedin()
        {
            if (Api.Auth.IsLoggedIn)
            {
                return;
            }

            var storage = new Storage();

            string loggedInName     = storage.LoadFromLocal(StorageKeys.LoggedInName)?.ToString() ?? string.Empty;
            string loggedInPassword = storage.LoadFromLocal(StorageKeys.LoggedInPassword)?.ToString() ?? string.Empty;

            if (string.IsNullOrEmpty(loggedInName) || string.IsNullOrEmpty(loggedInPassword))
            {
                Frame.Navigate(typeof(Login));
                return;
            }

            var  loginScrape = new Api.Authentication.LoginScrape(loggedInName, loggedInPassword);
            bool isLoggedIn  = loginScrape.Execute();

            if (!isLoggedIn)
            {
                Frame.Navigate(typeof(Login));
                return;
            }
        }
Esempio n. 2
0
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            string email    = LoginTextBox.Text;
            string password = PasswordTextBox.Password;

            //do login, if worked, save email and password
            var  loginScrape = new Api.Authentication.LoginScrape(email, password);
            bool isLoggedIn  = loginScrape.Execute();

            if (isLoggedIn)
            {
                var storage = new Storage();
                storage.StoreInLocal(StorageKeys.LoggedInName, email);
                storage.StoreInLocal(StorageKeys.LoggedInPassword, password);

                Frame.Navigate(typeof(MainPage));
            }
            else
            {
                //show message
                ErrorMessage.Visibility = Visibility.Visible;
            }
        }