Exemplo n.º 1
0
        void OnButtonReleased1(object sender, EventArgs args)
        {
            LogInButton.BackgroundColor = Color.FromHex("#2b2b2b"); //sets button color to original color in Hexadecimal.
            try                                                     //ensures neither of the entry fields are empty/null. Will only run with at least some input. Checks if entries are correct.
            {
                string User   = EmailEntry.Text.ToUpper();          //currently the "username" field, was originally meant to be email + access code below, was changed for current functionality.
                string Access = CodeEntry.Text.ToUpper();

                if (User == "BRIGHTENYOURBEING" && Access == "BEING")  //checks to see if the access code entry and User is exactly correct after being set to upper, decision by Lori to eliminate worry of capitalization.
                {
                    DirectoryPage directorypage = new DirectoryPage(); //Creates an instance of the DirectoryPage form called "directorypage"
                    Navigation.PushModalAsync(directorypage);          //Opens new DirectoryPage using the name "directorypage"
                }
                else if (User == "BRIGHTENYOURBEING" && Access != "BEING")
                {
                    DisplayAlert("Incorrect Code", "The Access Code you used was invalid", "Ok"); //structure of display alert is header, body, ok text, cancel text, or header, body, ok if only 3 entries.
                }
                else if (User != "BRIGTENYOURBEING" && Access == "BEING")
                {
                    DisplayAlert("Incorrect User", "The Username you used was invalid", "Ok");
                }
                else
                {
                    DisplayAlert("Incorrect Login", "The Username and Access Code you used was invalid", "Ok");
                }
            }
            catch //displays an alert when at least 1 of the two entries are empty
            {
                DisplayAlert("entry field Error", "Username and Access Code cannot be empty", "Ok");
            }
        }
        async void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
        {
            var authenticator = sender as OAuth2Authenticator;

            if (authenticator != null)
            {
                authenticator.Completed -= OnAuthCompleted;
                authenticator.Error     -= OnAuthError;
            }


            if (e.IsAuthenticated)
            {
                DirectoryPage directorypage = new DirectoryPage(); //Creates an instance of the DirectoryPage form called "directorypage"
                Navigation.PushModalAsync(directorypage);          //Opens new DirectoryPage using the name "directorypage"

                /*
                 * User user = null;
                 *
                 * // If the user is authenticated, request their basic user data from Google
                 * // UserInfoUrl = https://www.googleapis.com/oauth2/v2/userinfo
                 * var request = new OAuth2Request("GET", new Uri(Constants.GoogleUserInfoUrl), null, e.Account);
                 * var response = await request.GetResponseAsync();
                 * if (response != null)
                 * {
                 *  // Deserialize the data and store it in the account store
                 *  // The users email address will be used to identify data in SimpleDB
                 *  string userJson = await response.GetResponseTextAsync();
                 *  user = JsonConvert.DeserializeObject<User>(userJson);
                 * }
                 *
                 * if (account != null)
                 * {
                 *  store.Delete(account, Constants.AppName);
                 * }
                 *
                 * await store.SaveAsync(account = e.Account, Constants.AppName);
                 *
                 * Application.Current.Properties.Remove("Id");
                 * Application.Current.Properties.Remove("FirstName");
                 * Application.Current.Properties.Remove("LastName");
                 * Application.Current.Properties.Remove("DisplayName");
                 * Application.Current.Properties.Remove("EmailAddress");
                 * Application.Current.Properties.Remove("ProfilePicture");
                 *
                 * Application.Current.Properties.Add("Id", user.Id);
                 * Application.Current.Properties.Add("FirstName", user.GivenName);
                 * Application.Current.Properties.Add("LastName", user.FamilyName);
                 * Application.Current.Properties.Add("DisplayName", user.Name);
                 * Application.Current.Properties.Add("EmailAddress", user.Email);
                 * Application.Current.Properties.Add("ProfilePicture", user.Picture);
                 *
                 * await Navigation.PushAsync(new ProfilePage()); */
            }
        }