Пример #1
0
        /// <summary>
        /// Verifies the users login. 
        /// </summary>
        /// <param name="user"></param>
        /// <param name="id"></param>
        /// <param name="retUser"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool LoginAuthentication(User user, out int id, out User retUser, out String info)
        {
            List<String> errors;

            if (user.ValidateLogin(out errors))
            {
                info = "Welcome.aspx";
                if ((id = SelectUser("tblUser", user.CreateDict(), out retUser)) < 0)
                {
                    info = "Incorrect username and/or password";
                    return false;
                }

                return true;
            }
            else
            {
                info = "There are the following errors:";
                foreach (String error in errors)
                {
                    info += "\\n" + error;
                }
                retUser = null;
                id = -1;
                return false;
            }
        }
Пример #2
0
 /// <summary>
 /// Insert a new user into the database. 
 /// Returns a string to let the user know the insert was successful
 /// or outputs the database error message.
 /// </summary>
 /// <param name="first_name"></param>
 /// <param name="last_name"></param>
 /// <param name="username"></param>
 /// <param name="password"></param>
 /// <param name="securityQuestion"></param>
 /// <param name="securityAnswer"></param>
 /// <returns></returns>
 public bool InsertNewUser(User user, out String info)
 {
     List<String> errors = null;
     if (user.ValidateRegister(out errors))
     {
         info = InsertData("tblUser", user.CreateDict());
         return true;
     }
     else
     {
         info = "There are the following errors:";
         foreach (String error in errors)
         {
             info += "\\n" + error;
         }
         return false;
     }
 }