#include <cstdlib>
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main()
{
string pass;
string username;
bool admin;
bool blogin = false;
//Hack protection, because blogin shouldnt = true yet. Now if you call a function that does this and u use it multiple times, dont do this.
if(blogin == true || admin == true)
{
return 0;
}
map <string,string> login;
map <string,string> adminlogin;
adminlogin["Dutch"] = "password"; // Dutch (the username) is the name of the map element and "password" is the actual string for the password.
while(blogin == false)
{
cout << "Please enter your username" << endl;
cin >> username;
cout << "Please enter you pass" << endl;
cin >> pass;
if(pass == adminlogin[username])
{
cout << "Welcome " << username << " You are an admin" << endl;
admin = true; // YOu can give them special permissions if this is true..
blogin = true;
}
else if(pass == login[username])
{
cout << "Welcome " << username << endl;
blogin = true;
}
else
{
cout << "Login Failed please try again" << endl;
system("cls");
}
}
return 0;
}
#include <cstdlib>
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main()
{
string pass;
string username;
bool admin;
bool blogin = false;
//Hack protection, because blogin shouldnt = true yet. Now if you call a function that does this and u use it multiple times, dont do this.
if(blogin == true || admin == true)
{
return 0;
}
map <string,string> login;
map <string,string> adminlogin;
adminlogin["Dutch"] = "password"; // Dutch (the username) is the name of the map element and "password" is the actual string for the password.
while(blogin == false)
{
cout << "Please enter your username" << endl;
cin >> username;
cout << "Please enter you pass" << endl;
cin >> pass;
if(pass == adminlogin[username])
{
cout << "Welcome " << username << " You are an admin" << endl;
admin = true; // YOu can give them special permissions if this is true..
blogin = true;
}
else if(pass == login[username])
{
cout << "Welcome " << username << endl;
blogin = true;
}
else
{
cout << "Login Failed please try again" << endl;
system("cls");
}
}
return 0;
}
#include<iostream>
#include <string>
#include "drawMenu.h"
using namespace std;
void handelDisplay();
void accessDenied()
{
system("cls");
cout<<"\a\n\tAccess Denied, You need level 1 clearence!";
Sleep(3500);
return;
}
class CDetails
{
public:
string username;
string password;
short accessLevel;
CDetails() {};
CDetails(string setUser, string setPass, bool setAccess);
void displaySlot();
void getDetails();
bool checkDetails(string checkUser, string checkPass);
};
CDetails *slot_a = new CDetails ( "slot 1" , "default" , 0 );
CDetails *slot_b = new CDetails ( "slot 2" , "default" , 0 );
CDetails *slot_c = new CDetails ( "slot 3" , "default" , 1 );
void CDetails::getDetails()
{
if(accessLevel)
{
accessDenied();
return;
}
system("cls");
cout<<"\n\tEnter new username: ";getline(cin,username);
cout<<"\tEnter new password: ";getline(cin,password);
return;
}
CDetails::CDetails(string setUser, string setPass, bool setAccess)
{
username = setUser;
password = setPass;
accessLevel = setAccess;
}
void CDetails::displaySlot()
{
system("cls");
if(accessLevel)
{
accessDenied();
return;
}
cout<<"\n\tUsername: "<<username<<endl;
cout<<"\tPassword: "<<password<<endl;
cout<<"\t"; system("pause");
return;
}
bool CDetails::checkDetails(string checkUser, string checkPass)
{
if(checkUser == username && checkPass == password)
{
if(accessLevel)
{
accessDenied();
return false;
}
return true;
}
else
return false;
}
bool login()
{
string tempUser, tempPass;
system("cls");
cout<<"\n\tEnter username: "; getline(cin,tempUser);
cout<<"\tEnter password: "; getline(cin,tempPass);
system("cls");
if(slot_a->checkDetails(tempUser,tempPass))
return true;
else if (slot_b->checkDetails(tempUser,tempPass))
return true;
else if (slot_c->checkDetails(tempUser,tempPass))
return true;
else
return false;
}
void handelLogin()
{
if(login())
{
cout<<"\n\tYou have logged in successfully!";
}
else
{
cout<<"\n\t\aInccorect log in!";
}
Sleep(2500);
return;
}
void setDetails()
{
system("cls");
string names;
for(;
{
names="";
names += slot_a->username;
names += "|";
names += slot_b->username;
names += "|";
names += slot_c->username;
names += "|";
names += "Return";
system("cls");
cout<<endl;
switch(drawMenu("Set login details",names,1))
{
case 1: slot_a->getDetails();break;
case 2: slot_b->getDetails();break;
case 3: slot_c->getDetails();break;
case 4: return;
}
}
}
int main()
{
bool quit = 0;
for(;
{
system("cls");
cout<<endl;
switch(drawMenu("Welcome to my log in console","Login|Check Details|Set details|Exit",1))
{
case 1: handelLogin();break;
case 2: handelDisplay();break;
case 3: setDetails();break;
case 4: quit = 1; break;
}
if(quit)
break;
}
delete &slot_a;
delete &slot_b;
delete &slot_c;
return 0;
}
void handelDisplay()
{
system("cls");
string names;
names += slot_a->username;
names += "|";
names += slot_b->username;
names += "|";
names += slot_c->username;
names += "|";
names += "Return";
for(;
{
system("cls");
cout<<endl;
switch(drawMenu("Check login details",names,1))
{
case 1: slot_a->displaySlot();break;
case 2: slot_b->displaySlot();break;
case 3: slot_c->displaySlot();break;
case 4: return;
}
}
}
#include<iostream>
#include <string>
#include "drawMenu.h"
using namespace std;
void handelDisplay();
void accessDenied()
{
system("cls");
cout<<"\a\n\tAccess Denied, You need level 1 clearence!";
Sleep(3500);
return;
}
class CDetails
{
public:
string username;
string password;
short accessLevel;
CDetails() {};
CDetails(string setUser, string setPass, bool setAccess);
void displaySlot();
void getDetails();
bool checkDetails(string checkUser, string checkPass);
};
CDetails *slot_a = new CDetails ( "slot 1" , "default" , 0 );
CDetails *slot_b = new CDetails ( "slot 2" , "default" , 0 );
CDetails *slot_c = new CDetails ( "slot 3" , "default" , 1 );
void CDetails::getDetails()
{
if(accessLevel)
{
accessDenied();
return;
}
system("cls");
cout<<"\n\tEnter new username: ";getline(cin,username);
cout<<"\tEnter new password: ";getline(cin,password);
return;
}
CDetails::CDetails(string setUser, string setPass, bool setAccess)
{
username = setUser;
password = setPass;
accessLevel = setAccess;
}
void CDetails::displaySlot()
{
system("cls");
if(accessLevel)
{
accessDenied();
return;
}
cout<<"\n\tUsername: "<<username<<endl;
cout<<"\tPassword: "<<password<<endl;
cout<<"\t"; system("pause");
return;
}
bool CDetails::checkDetails(string checkUser, string checkPass)
{
if(checkUser == username && checkPass == password)
{
if(accessLevel)
{
accessDenied();
return false;
}
return true;
}
else
return false;
}
bool login()
{
string tempUser, tempPass;
system("cls");
cout<<"\n\tEnter username: "; getline(cin,tempUser);
cout<<"\tEnter password: "; getline(cin,tempPass);
system("cls");
if(slot_a->checkDetails(tempUser,tempPass))
return true;
else if (slot_b->checkDetails(tempUser,tempPass))
return true;
else if (slot_c->checkDetails(tempUser,tempPass))
return true;
else
return false;
}
void handelLogin()
{
if(login())
{
cout<<"\n\tYou have logged in successfully!";
}
else
{
cout<<"\n\t\aInccorect log in!";
}
Sleep(2500);
return;
}
void setDetails()
{
system("cls");
string names;
for(;
{
names="";
names += slot_a->username;
names += "|";
names += slot_b->username;
names += "|";
names += slot_c->username;
names += "|";
names += "Return";
system("cls");
cout<<endl;
switch(drawMenu("Set login details",names,1))
{
case 1: slot_a->getDetails();break;
case 2: slot_b->getDetails();break;
case 3: slot_c->getDetails();break;
case 4: return;
}
}
}
int main()
{
bool quit = 0;
for(;
{
system("cls");
cout<<endl;
switch(drawMenu("Welcome to my log in console","Login|Check Details|Set details|Exit",1))
{
case 1: handelLogin();break;
case 2: handelDisplay();break;
case 3: setDetails();break;
case 4: quit = 1; break;
}
if(quit)
break;
}
delete &slot_a;
delete &slot_b;
delete &slot_c;
return 0;
}
void handelDisplay()
{
system("cls");
string names;
names += slot_a->username;
names += "|";
names += slot_b->username;
names += "|";
names += slot_c->username;
names += "|";
names += "Return";
for(;
{
system("cls");
cout<<endl;
switch(drawMenu("Check login details",names,1))
{
case 1: slot_a->displaySlot();break;
case 2: slot_b->displaySlot();break;
case 3: slot_c->displaySlot();break;
case 4: return;
}
}
}
Copyright © 2024, NextGenUpdate.
All Rights Reserved.