Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef LOGING_H
- #define LOGIN_H
- #include "feed.h"
- #include <iostream>
- #include <vector>
- using namespace std;
- class LogInInfo {
- vector<string> usernames;
- vector<string> passwords;
- public:
- void welcomePage() {
- int menuChoice;
- cout << "\nChirpy\n===========================\n"
- << "1) Log in\n2) Sign Up\n" << endl;
- cin >> menuChoice;
- switch (menuChoice) {
- case 1: checkUser();
- break;
- case 2: createUser();
- break;
- default: cout << "Not an option\n";
- welcomePage();
- }
- welcomePage();
- }
- void createUser() {
- string username, password;
- int namePlace = 0;
- cout << "Enter new username:\n>> ";
- cin >> username;
- for (int x = 0 ; x < usernames.size() ; x++) {
- if (username == usernames[x]) {
- cout << "That name is already taken\n" << endl;
- createUser();
- }
- namePlace = x;
- }
- usernames.push_back(username);
- cout << "\nWelcome " << usernames[namePlace] << endl;
- cout << "Enter Password:\n>> ";
- cin >> password;
- passwords.push_back(password);
- postToFeed();
- welcomePage();
- }
- void checkUser() {
- string username, password;
- int location;
- cout << "Enter your username:\n>> ";
- cin >> username;
- for (int x = 0 ; x < usernames.size() ; x++) {
- if (username == usernames[x]) {
- cout << "\nWelcome " << usernames[x] << endl;
- cout << "Enter your password:\n>> ";
- cin >> password;
- if (password == passwords[x]) {
- cout << "\nSucessfully Loged in\n" << endl;
- postToFeed();
- }
- else {
- cout << "\nPassword not found. Going back to menu.\n" << endl;
- welcomePage();
- }
- }
- else {
- cout << "\nUsername not found. Going back to menu.\n" << endl;
- welcomePage();
- }
- }
- }
- void postToFeed() {
- Myfeed *goToFeed = new Myfeed;
- goToFeed->mainMenu();
- }
- };
- #endif
Add Comment
Please, Sign In to add comment