Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication6.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <Windows.h>
- #include <string>
- #include "UserPass.h"
- std::string username()
- {
- std::string user;
- std::cout << "Username: ";
- std::cin >> user;
- if (user.length() < 13) { return user; }
- }
- std::string password()
- {
- std::string pass;
- std::cout << "Password: ";
- std::cin >> pass;
- if (pass.length() < 17) { return pass; }
- }
- void login()
- {
- std::cout << "Logging in...\n";
- Sleep(3000);
- std::cout << "Successfully logged in!\n";
- system("pause");
- }
- std::string input()
- {
- std::string in;
- std::cin >> in;
- return in;
- }
- int main();
- void inputs()
- {
- std::cout << "Type \"cmds\" to begin!\n";
- if (input() == "cmds")
- {
- std::cout << "1 = Change Username\n";
- std::cout << "2 = Change Password\n";
- }
- std::string in = input();
- if (in == "2")
- {
- std::string newPass;
- std::string confirmPass;
- std::string currPass;
- std::cout << "Current Password: ";
- std::cin >> currPass;
- if (currPass == UserNPass::passW)
- {
- std::cout << "\nNew Password: ";
- std::cin >> newPass;
- std::cout << "\nConfirm Password: ";
- std::cin >> confirmPass;
- if (newPass == confirmPass)
- {
- UserNPass::passW = newPass;
- system("cls");
- main();
- }
- else
- {
- std::cout << "New Password and Confirm Password do not match!\n";
- }
- }
- }
- else if (in == "1")
- {
- std::string newUser;
- std::cout << "\nNew Username: ";
- std::cin >> newUser;
- UserNPass::userN = newUser;
- system("cls");
- main();
- }
- }
- int main()
- {
- if (username() == UserNPass::userN && password() == UserNPass::passW)
- {
- std::cout << "Authorizing...\n";
- Sleep(2000);
- login();
- inputs();
- }
- else
- {
- std::cout << "Authorizing...\n";
- Sleep(2000);
- std::cout << "Wrong password/username!";
- Sleep(2000);
- system("cls");
- main();
- }
- return 0;
- }
- ---------- UserNPass HEADER FILE ----------
- #pragma once
- #include <string>
- namespace UserNPass {
- std::string userN = "admin";
- std::string passW = "admin123";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement