Guest User

Untitled

a guest
Aug 4th, 2020
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1.     void setAdminAuthenticate(const string& path, const string& login, const string& password)
  2.     {
  3.         fstream fs;
  4.         fs.open(path, fstream::in | fstream::out | fstream::binary);
  5.         if (!fs.is_open())
  6.         {
  7.             throw file_not_found("Error! File not found!");
  8.         }
  9.         else
  10.         {
  11.             int temp_size = 0;
  12.             fs.read((char*)& temp_size, sizeof(int));
  13.             if (temp_size == 0)
  14.             {
  15.                 throw exception("Error! You are not registered in the system!");
  16.             }
  17.             else
  18.             {
  19.                 string temp_login = "";
  20.                 string temp_password = "";
  21.                 fs.read((char*)& temp_login, sizeof(string));
  22.                 fs.read((char*)& temp_password, sizeof(string));
  23.                 if (temp_login == login and temp_password == password)
  24.                 {
  25.                     m_login = login;
  26.                     m_password = login;
  27.                 }
  28.                 else
  29.                 {
  30.                     throw exception("Error! You entered incorrectly login or password!");
  31.                 }
  32.             }
  33.         }
  34.         fs.close();
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment