my program only allow userdata from "userdatabase.txt" to enter when ask for login and password. but now I anyhow type also can login.
can anyone tell me where is the problem.
void authUser() // Function that prompts for user to login and matches input with userdatabase.txt
{
string accountID = ""; // initialize temp accountID to null
string password = ""; // initialize temp password to null
int invalidCount = 0;
char c = ' ';
bool validUser = false;
bool failedLogin = false;
while (validUser != true) // to check for invalid login
{
system("clear");
using std :: cout;
using std :: endl;
void Encrypt( char [ ] ); // prototypes of functions used in the code
void Decrypt( char * ePtr );
cout << logo_MainMenu << endl;
if (failedLogin == true) // Displays error before asking for username/password
{
if (invalidCount == 1) // tests for invalid login, 1 / 3 chance used up
{
cout << "\E[1;32mInvalid Account ID / Password. Please try again!\E[0m" << endl;
cout << "You have used up 1 / 3 chances to login." << endl;
cout << "If you fail to login after 3 tries, the application will lock down and exit!" << endl;
}
else if (invalidCount == 2) // tests for invalid login, 2 / 3 chance used up
{
cout << "\E[1;32mInvalid Account ID / Password. Please try again!\E[0m" << endl;
cout << "You have used up 2 / 3 chances to login." << endl;
cout << "If you fail to login after 3 tries, the application will lock down and exit!" << endl;
}
else // tests for invalid login, 3 / 3 chance used up
{
cout << "\E[1;32mInvalid Account ID / Password.\E[0m" << endl;
cout << "You have used up 3 / 3 chances to login." << endl << endl;
cout << "The application will now lock down and exit!" << endl;
exit (0); // exit application
}
}
cout << endl << "To login, please enter your Account ID and Password" << endl;
cout << "(type \"exit\" to terminate the application)" << endl << endl;
cout << "Account ID: ";
getline (cin, accountID);
if (accountID == "exit") // user can exit anytime
exit (0);
// by typing "exit" at username or password
if (password == "exit")
exit (0);
char clear[200] = {0};
char cipher[200] = {0}; // trying to to encrypting and decrypt
char filename[80];
int x,i;
ofstream outputFile;
outputFile.open("yxy.txt"); // the text file that my encrypted password goes into
ifstream userDatabaseIN("userdatabase.txt", ios::in); // the text file that userdata is stored at
cout << "Enter Password:" ; // asking for password
cin.getline(clear,sizeof(clear));