Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- void Login();
- bool CheckCredentials(string, string);
- int main()
- {
- string username;
- string password;
- Login();
- CheckCredentials(username, password);
- return 0;
- }
- void Login()
- {
- ifstream infile;
- string username;
- string password;
- int tries = 1;
- cout << "Enter in your username and password." << endl;
- cout << "Username: ";
- cin >> username;
- cout << "Password: ";
- cin >> password;
- while (!CheckCredentials(username, password) && tries < 3)
- {
- cout << "Wrong password or username. you have " << 3 - tries << " tries left" << endl;
- tries++;
- cout << "Enter in your username and password." << endl;
- cout << "Username: ";
- cin >> username;
- cout << "Password: ";
- cin >> password;
- }
- if (tries > 2)
- {
- cout << "You have exceeded the maximum amount of attempts. Try again in 24 hours." << endl;
- }
- if (CheckCredentials(username, password))
- {
- cout << "Access Granted" << endl;
- }
- }
- bool CheckCredentials(string username, string password)
- {
- string cUser, cPass;
- ifstream infile;
- getline(infile, cUser);
- getline(infile, cPass);
- if (username == cUser && password == cPass)
- {
- }
- else
- {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement