Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. class loginManager {
  7. public:
  8. loginManager() {
  9. accessGranted = 0;
  10. }
  11. void login() {
  12. cout << "Passwort eingeben. \nUsername:";
  13. cin >> userNameAttempt;
  14.  
  15. userName = getFile("users.txt");
  16. if (userNameAttempt == userName) {
  17. cout << "Passwort:";
  18. cin >> passWordAttempt;
  19.  
  20. passWord = getFile("pswds.txt");
  21. if (passWordAttempt == passWord) {
  22. cout << "Richtiges password";
  23. cin.get();
  24. }
  25. else {
  26. cout << "Falsch." << endl;
  27. login();
  28. }
  29. }
  30. else {
  31. cout << "Ne." << endl;
  32. login();
  33. }
  34. }
  35. string getFile(const char* p_fileName){
  36. string line;
  37. fstream file;
  38.  
  39. file.open(p_fileName, ios::in);
  40. if (file.is_open())
  41. {
  42. getline(file, line);
  43. }
  44. file.close();
  45.  
  46. return line;
  47. }
  48.  
  49. private:
  50. string passWord = "password123";
  51. string userName = "user@user";
  52. string userNameAttempt;
  53. string passWordAttempt;
  54. bool accessGranted;
  55. };
  56.  
  57. int main() {
  58. loginManager loginManagerObj;
  59. loginManagerObj.login();
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement