Guest User

Untitled

a guest
Aug 4th, 2020
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. // ADMIN registration and authenticate
  2.     void setAdminRegistration(const string& path, const string& login, const string& password)
  3.     {
  4.         if (login.size() == 0 and password.size() == 0)
  5.         {
  6.             throw exception("Error! Entered incorrectly login or password!");
  7.         }
  8.         else
  9.         {
  10.             //fstream in;
  11.             //in.open(path, fstream::in | fstream::out | fstream::trunc);
  12.             ifstream fin(path, ios::in);
  13.             int size1 = sizeFile(path);
  14.             if (!fin.is_open())
  15.             {
  16.                 throw file_not_found("Error! File not found!");
  17.             }
  18.             else
  19.             {
  20.                 Adminstrator temp(login, password);
  21.                 int temp_size = Adminstrator::adminID;
  22.                 fin >> temp_size;
  23.                 fin.ignore();
  24.                 getline(fin >> ws, temp.login);
  25.                 getline(fin >> ws, temp.password);
  26.             }
  27.             int size2 = sizeFile(path);
  28.             if (size1 == size2)
  29.             {
  30.                 throw exception("Error! The system crashed!\n");
  31.             }
  32.             fin.close();
  33.         }
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment