Advertisement
Guest User

code

a guest
Jul 14th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.13 KB | None | 0 0
  1. // ConsoleApplication6.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <Windows.h>
  7. #include <string>
  8. #include "UserPass.h"
  9.  
  10. std::string username()
  11. {
  12.     std::string user;
  13.     std::cout << "Username: ";
  14.     std::cin >> user;
  15.     if (user.length() < 13) { return user; }
  16.  
  17. }
  18.  
  19. std::string password()
  20. {
  21.     std::string pass;
  22.     std::cout << "Password: ";
  23.     std::cin >> pass;
  24.     if (pass.length() < 17) { return pass; }
  25.  
  26. }
  27. void login()
  28. {
  29.     std::cout << "Logging in...\n";
  30.     Sleep(3000);
  31.     std::cout << "Successfully logged in!\n";
  32.     system("pause");
  33. }
  34.  
  35. std::string input()
  36. {
  37.  
  38.     std::string in;
  39.     std::cin >> in;
  40.     return in;
  41.  
  42. }
  43.  
  44. int main();
  45.  
  46. void inputs()
  47. {
  48.     std::cout << "Type \"cmds\" to begin!\n";
  49.     if (input() == "cmds")
  50.     {
  51.         std::cout << "1 = Change Username\n";
  52.         std::cout << "2 = Change Password\n";
  53.     }
  54.     std::string in = input();
  55.     if (in == "2")
  56.     {
  57.         std::string newPass;
  58.         std::string confirmPass;
  59.         std::string currPass;
  60.         std::cout << "Current Password: ";
  61.         std::cin >> currPass;
  62.         if (currPass == UserNPass::passW)
  63.         {
  64.             std::cout << "\nNew Password: ";
  65.             std::cin >> newPass;
  66.             std::cout << "\nConfirm Password: ";
  67.             std::cin >> confirmPass;
  68.             if (newPass == confirmPass)
  69.             {
  70.                 UserNPass::passW = newPass;
  71.                 system("cls");
  72.                 main();
  73.             }
  74.             else
  75.             {
  76.                 std::cout << "New Password and Confirm Password do not match!\n";
  77.             }
  78.         }
  79.  
  80.     }
  81.     else if (in == "1")
  82.     {
  83.         std::string newUser;
  84.         std::cout << "\nNew Username: ";
  85.         std::cin >> newUser;
  86.         UserNPass::userN = newUser;
  87.         system("cls");
  88.         main();
  89.     }
  90. }
  91.  
  92. int main()
  93. {
  94.     if (username() == UserNPass::userN && password() == UserNPass::passW)
  95.     {
  96.         std::cout << "Authorizing...\n";
  97.         Sleep(2000);
  98.         login();
  99.         inputs();
  100.     }
  101.     else
  102.     {
  103.         std::cout << "Authorizing...\n";
  104.         Sleep(2000);
  105.         std::cout << "Wrong password/username!";
  106.         Sleep(2000);
  107.         system("cls");
  108.         main();
  109.     }
  110.  
  111.     return 0;
  112. }
  113.  
  114.  
  115. ---------- UserNPass HEADER FILE ----------
  116.  
  117.  
  118. #pragma once
  119.  
  120. #include <string>
  121.  
  122. namespace UserNPass {
  123. std::string userN = "admin";
  124. std::string passW = "admin123";
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement