private void SignIn_Click(object sender, RoutedEventArgs e)
        {
            int index = GlobalData.Instance.accountList.IndexOf(UserInput.Text);

            if (GlobalData.Instance.accountList.Contains(UserInput.Text) && (PasswordInput.Password).Equals(GlobalData.Instance.accountList[index + 2]))
            {
                ProfileMainPage profileMainPage = new ProfileMainPage(UserInput.Text, GlobalData.Instance.accountList[index + 1], PasswordInput.Password);
                GlobalData.Instance.signedIn = true;
                signInMain.Content           = profileMainPage;
            }
            else
            {
                _name.Foreground  = Brushes.Red;
                _pass.Foreground  = Brushes.Red;
                invalidInput.Text = "Invalid username or password";
            }
        }
Example #2
0
        private void SignUp_Click(object sender, RoutedEventArgs e)
        {
            if (nameInput.Text == "" || emailInput.Text == "" || passwordInput.Password.Length == 0)
            {
                if (nameInput.Text == "")
                {
                    nameText.Foreground = Brushes.Red;
                }
                if (emailInput.Text == "")
                {
                    emailText.Foreground = Brushes.Red;
                }
                if (passwordInput.Password.Length == 0)
                {
                    passText.Foreground = Brushes.Red;
                }

                invalidInput.Text = "Highlighted field(s) are required.";
            }
            else if (nameInput.Text.Length < 4)
            {
                invalidInput.Text   = "Username needs to be at least 4 characters.";
                nameText.Foreground = Brushes.Red;
            }
            else if (passwordInput.Password.Length < 8)
            {
                invalidInput.Text   = "Password needs to be at least 8 characters.";
                passText.Foreground = Brushes.Red;
            }
            else if (!(passwordInput.Password.Contains("1") || passwordInput.Password.Contains("2") || passwordInput.Password.Contains("3") || passwordInput.Password.Contains("4") || passwordInput.Password.Contains("5") || passwordInput.Password.Contains("6") || passwordInput.Password.Contains("7") || passwordInput.Password.Contains("8") || passwordInput.Password.Contains("9") || passwordInput.Password.Contains("0")))
            {
                invalidInput.Text   = "Password needs to contain at least 1 digit.";
                passText.Foreground = Brushes.Red;
            }
            else
            {
                ProfileMainPage profileMainPage = new ProfileMainPage(nameInput.Text, emailInput.Text, passwordInput.Password);
                GlobalData.Instance.signedIn = true;
                GlobalData.Instance.accountList.Add(nameInput.Text);
                GlobalData.Instance.accountList.Add(emailInput.Text);
                GlobalData.Instance.accountList.Add(passwordInput.Password);
                GlobalData.Instance.accountList.Add("");
                GlobalData.Instance.accountList.Add("");
                signUpMain.Content = profileMainPage;
            }
        }