void ReadAdmins() { std::ifstream in("./data/admins.txt", std::ios::in); admins.clear(); Administrator tmp; while (in >> tmp) { admins.push_back(tmp); tmp = Administrator(); } }
void MainProgramWindow::on_pushButton_Login_clicked() { Admin Administrator("admin","*****@*****.**", 1234, "password"); int customerLocation; bool validInput = false; QString tempName; QString tempPassword; Login loginWindow; ErrorLogin errorWindow; Customer tempCustomer; customerLocation = 0; loginWindow.setModal(true); int success = loginWindow.exec(); loginWindow.on_buttonBox_loginPress_accepted(tempName, tempPassword); // Stores the tempname and password SetUsername(tempName); SetPassword(tempPassword); if(Administrator.checkAdmin(tempName, tempPassword )) { validInput = true; SetAdminLogin(true); } else { // Compare user input to database try { tempCustomer = customerList.FindCustomer(tempName); if (tempCustomer.getAccess() && tempCustomer.getPassword() == tempPassword) { validInput = true; SetCustomerLogin(true); } else if (tempCustomer.getPassword() != tempPassword) { QMessageBox::information(this,"Error", "Wrong Credentials, sorry."); } else { QMessageBox::information(this,"Message", "Your account has not been activated yet. An administrator needs to activate your account, thank you for your patience!"); } } catch (NotFound) { if (success) { QMessageBox::information(this,"Error", "Account not found, sorry."); } } catch(...) { } } if(validInput) { if(adminLogin) { aWindow->show(); // ADMIN } else if(customerLogin) { if(tempCustomer.getAccess()) { bWindow->show(); // BROCHURE } } } //restore defaults SetAdminLogin(false); SetCustomerLogin(false); }