/// <summary>
        /// Takes in User information from the database and creates an user Object with that information
        /// </summary>
        /// <param name="tableName">the name of the table that the Object information is saved</param>
        /// <param name="userNumber">the users number to identify which user to create an Object for</param>
        private void SetRowToObject(int userNumber)
        {
            string tableRow = database.RetrieveTableRow(database.TableName, userNumber);

            string[] split = tableRow.Split(separator: '\n');
            user.UserName = split[0];
            user.Email    = split[1];
            user.Password = split[2];
            user.Score    = split[3];
        }
Beispiel #2
0
        /// <summary>
        /// Validates email and password for login and retrieves user data.
        /// </summary>
        /// <param name="email">The user's email</param>
        /// <param name="password">The user's password</param>
        /// <returns></returns>
        public Boolean AuthenticateUser(string email, string password)
        {
            string userData = "";

            string[] splitRow;
            for (int i = 1; i <= database.RetrieveNumberOfRowsInTable(); i++)
            {
                userData = database.RetrieveTableRow(database.TableName, i);
                splitRow = userData.Split(separator: '\n');
                if (splitRow[1].Equals(email) && splitRow[2].Equals(password))
                {
                    user.UserName = splitRow[0];
                    user.Email    = splitRow[1];
                    user.Password = splitRow[2];
                    user.Score    = splitRow[3];
                    return(true);
                }
            }

            return(false);
        }