Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- class loginManager {
- public:
- loginManager() {
- accessGranted = 0;
- }
- void login() {
- cout << "Passwort eingeben. \nUsername:";
- cin >> userNameAttempt;
- userName = getFile("users.txt");
- if (userNameAttempt == userName) {
- cout << "Passwort:";
- cin >> passWordAttempt;
- passWord = getFile("pswds.txt");
- if (passWordAttempt == passWord) {
- cout << "Richtiges password";
- cin.get();
- }
- else {
- cout << "Falsch." << endl;
- login();
- }
- }
- else {
- cout << "Ne." << endl;
- login();
- }
- }
- string getFile(const char* p_fileName){
- string line;
- fstream file;
- file.open(p_fileName, ios::in);
- if (file.is_open())
- {
- getline(file, line);
- }
- file.close();
- return line;
- }
- private:
- string passWord = "password123";
- string userName = "user@user";
- string userNameAttempt;
- string passWordAttempt;
- bool accessGranted;
- };
- int main() {
- loginManager loginManagerObj;
- loginManagerObj.login();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement