Beispiel #1
0
        private void Add_User_Confirm_Click(object sender, RoutedEventArgs e)
        {
            // username is email
            string username = Add_User_Name.Text;

            if (GlobalVariables.isEmailInPeople(username))
            {
                if (!DisplayUsernamesData.NAMES_IN.Contains(username))
                {
                    Group_Members.Text = Group_Members.Text + $"{GlobalVariables.returnName(username)} ({username})" + Environment.NewLine;

                    Add_User_Name.Text = "";
                    DisplayUsernamesData.TOTAL_USERNAMES++;
                    DisplayUsernamesData.NAMES_IN.Add(username);
                }
                else
                {
                    MessageBox.Show("User is already added to group");
                }
            }
            else
            {
                MessageBox.Show("User is not in database!");
            }
        }
Beispiel #2
0
        private void LoginDown(object sender, RoutedEventArgs e)
        {
            var canContinue = true;
            var userPass    = true;
            var studentPass = true;
            var password    = PasswordBox.Password;

            var user = UserName.Text;

            //Check user in database//// Idk How XD

            if (GlobalVariables.isUsernameInPeople(user) == false)
            {
                ErrorBox.Foreground = new BrushConverter().ConvertFromString("#3dff11") as SolidColorBrush;
                ErrorBox.Text       = "User not found";
                userPass            = false;
            }
            if (GlobalVariables.isEmailInPeople(user) == false)
            {
                ErrorBox.Foreground = new BrushConverter().ConvertFromString("#3dff11") as SolidColorBrush;
                ErrorBox.Text       = "Student Code not found";
                studentPass         = false;
            }

            if (GlobalVariables.IsDigitsOnly(user))
            {
                if (GlobalVariables.isCorrectPasswordEmail(password, int.Parse(user)) == false)
                {
                    ErrorBox.Foreground = new BrushConverter().ConvertFromString("#3dff11") as SolidColorBrush;
                    ErrorBox.Text       = "Incorrect Password";
                    canContinue         = false;
                }
            }
            else
            {
                if (GlobalVariables.isCorrectPasswordUsername(password, user) == false)
                {
                    ErrorBox.Foreground = new BrushConverter().ConvertFromString("#3dff11") as SolidColorBrush;
                    ErrorBox.Text       = "Incorrect Password";
                    canContinue         = false;
                }
            }



            if (canContinue == true && (userPass || studentPass))
            {
                NavigationService navService = NavigationService.GetNavigationService(this);
                Groups_Page       nextPage   = new Groups_Page();
                navService.Navigate(nextPage);
            }
        }
Beispiel #3
0
        private void MakeUserNow(object sender, RoutedEventArgs e)
        {
            bool   Robbieisbudgesbestfriend = false;
            string StringAlpha = UserEnteredName.Text;
            bool   HasSpace    = StringAlpha.Contains(" ");
            string UserNameNow = UserEnteredName.Text.ToString();

            bool FirstNameContainsSpace = UserFirstName.Text.Contains(" ");
            bool LastNameContainsSpace  = UserLastName.Text.Contains(" ");

            bool FirstNameContainsWrong = false;
            bool LastNameContainsWrong  = false;

            if (UserFirstName.Text.Contains("\u0022"))
            {
                LastNameContainsWrong = true;
            }
            if (UserLastName.Text.Contains("\u0022"))
            {
                LastNameContainsWrong = true;
            }
            if (UserFirstName.Text.Contains("\u0027"))
            {
                LastNameContainsWrong = true;
            }
            if (UserLastName.Text.Contains("\u0027"))
            {
                LastNameContainsWrong = true;
            }

            if (UserEnteredCode.Text.Contains("\u0022"))
            {
                LastNameContainsWrong = true;
            }
            if (PasswordBoxConfirm.Password.Contains("\u0022"))
            {
                LastNameContainsWrong = true;
            }
            if (UserEnteredCode.Text.Contains("\u0027"))
            {
                LastNameContainsWrong = true;
            }
            if (PasswordBoxMake.Password.Contains("\u0027"))
            {
                LastNameContainsWrong = true;
            }
            if (PasswordBoxConfirm.Password.Contains("\u0027"))
            {
                LastNameContainsWrong = true;
            }
            if (PasswordBoxConfirm.Password.Contains("\u0022"))
            {
                LastNameContainsWrong = true;
            }



            if (UserFirstName.Text.Length < 2 || UserLastName.Text.Length < 2)
            {
                ErrorBox.Foreground      = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush;
                ErrorBox.Text            = "First or Last Name Too Short!";
                Robbieisbudgesbestfriend = true;
            }
            if (FirstNameContainsSpace || LastNameContainsSpace)
            {
                ErrorBox.Foreground      = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush;
                ErrorBox.Text            = "First or Last Name Contains A Space!";
                Robbieisbudgesbestfriend = true;
            }
            if (FirstNameContainsWrong || LastNameContainsWrong)
            {
                ErrorBox.Foreground      = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush;
                ErrorBox.Text            = "Please Do Not Use \" or \'";
                Robbieisbudgesbestfriend = true;
            }

            /*
             * if (PasswordBoxConfirm.Password == PasswordBoxMake.Password && UserEnteredName.Text != "User Name" && HasSpace == false)
             * {
             *  var NewPassword = PasswordBoxConfirm.Password;
             *  ErrorBox.Foreground = new BrushConverter().ConvertFromString("#3dff11") as SolidColorBrush;
             *  ErrorBox.Text = "User Created!";
             *  //add password to data base
             * }
             */

            if (UserEnteredName.Text == "User Name" || HasSpace || UserEnteredName.Text.Length < 5 || (UserNameNow.Contains('\u0022')) || (UserNameNow.Contains('\u0027')))
            {
                if (HasSpace)
                {
                    ErrorBox.Foreground = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush;
                    ErrorBox.Text       = "User Name Has Spaces!";
                }
                else if (UserEnteredName.Text.Length < 5)
                {
                    ErrorBox.Foreground = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush;
                    ErrorBox.Text       = "User Name To Short!";
                }
                else
                {
                    ErrorBox.Foreground = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush;
                    ErrorBox.Text       = "User Name Invalid";
                }
                Robbieisbudgesbestfriend = true;
            }

            if (PasswordBoxConfirm.Password != PasswordBoxMake.Password)
            {
                ErrorBox.Foreground      = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush;
                ErrorBox.Text            = "Passwords Do Not Match!";
                Robbieisbudgesbestfriend = true;
            }
            if (UserEnteredName.Text == "User Name" || HasSpace)
            {
                ErrorBox.Foreground      = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush;
                ErrorBox.Text            = "User Name Invalid!";
                Robbieisbudgesbestfriend = true;
            }
            if (PasswordBoxMake.Password == PasswordBoxConfirm.Password && PasswordBoxMake.Password.Length < 5)
            {
                ErrorBox.Foreground      = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush;
                ErrorBox.Text            = "Password To Short!";
                Robbieisbudgesbestfriend = true;
            }

            if (PasswordBoxMake.Password.Any(char.IsUpper))
            {
            }
            else
            {
                ErrorBox.Foreground = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush;
                ErrorBox.Text       = "Password Doesn't Meet Requirements!";
            }


            // Zachary's tests

            if (GlobalVariables.isEmailInPeople(UserEnteredCode.Text))
            {
                ErrorBox.Foreground      = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush;
                ErrorBox.Text            = "Student Code is already taken!";
                Robbieisbudgesbestfriend = true;
            }

            if (GlobalVariables.isUsernameInPeople(UserEnteredName.Text))
            {
                ErrorBox.Foreground      = new BrushConverter().ConvertFromString("#ff0000") as SolidColorBrush;
                ErrorBox.Text            = "Username is already taken!";
                Robbieisbudgesbestfriend = true;
            }


            // End of Zac's tests
            if (Robbieisbudgesbestfriend == false)
            {
                ErrorBox.Foreground    = new BrushConverter().ConvertFromString("#3dff11") as SolidColorBrush;
                ErrorBox.Text          = "User Created!";
                PublishUser.Visibility = Visibility.Hidden;
                Go_Login.Content       = "Go To Login";
                GlobalVariables.insertIntoPeople(UserFirstName.Text, UserLastName.Text, PasswordBoxConfirm.Password, int.Parse(UserEnteredCode.Text), UserEnteredName.Text);
            }
        }