Beispiel #1
0
        /// <summary>
        /// Upon addUser_Submit_Click the String in the TextBox and Password in the Password box will be applied sent to
        /// the constructor for an EasyPayUser to be created called newUser.
        /// newUSer will then be passed to the SQLLiteDataAccess SaveUser function, saving it to the database.
        /// A messagebox will display informing the user of a sucessful save.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void addUser_Submit_Click(object sender, RoutedEventArgs e)
        {
            String      un;        // To store username
            String      pw;        // To store entered password
            String      confirmPw; // To store confirmed password
            EasyPayUser newUser;   // Init new EasyPayUser

            // Store entered username and encrypted passwords
            un        = newUsername.Text;
            pw        = Encode_Decode.Encrypt(newPasswordBox.Password);
            confirmPw = Encode_Decode.Encrypt(confirmPasswordBox.Password);

            /* If password entered and confrirm passwords match, proceed to
             * create an EasyPayUser with data etered and save it to db
             * Inform user that a new user was added and open main window
             */
            if (pw == confirmPw)
            {
                newUser = new EasyPayUser(un, pw);
                SQLiteDataAccess.SaveUser(newUser);

                MessageBox.Show("New user added");

                MainWindow dashboard = new MainWindow();
                //dashboard.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("Please make sure passwords match");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Checks for a match between password entered and pasword saved in database for a given user based on index of
        /// the EasyPayUser in the List returned.
        /// </summary>
        /// <param name="index">int index of EasyPayUser location in List</param>
        /// <param name="pw">String password entered in login screen</param>
        /// <returns>True if password mathches pw at given index</returns>
        public static Boolean validPassword(int index, String pw)
        {
            List <EasyPayUser> userList    = SQLiteDataAccess.LoadUsers();
            EasyPayUser        currentUser = userList.ElementAt(index);

            if (Encode_Decode.Decrypt(currentUser.Password) == pw)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }