Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setAdminAuthenticate(const string& path, const string& login, const string& password)
- {
- fstream fs;
- fs.open(path, fstream::in | fstream::out | fstream::binary);
- if (!fs.is_open())
- {
- throw file_not_found("Error! File not found!");
- }
- else
- {
- int temp_size = 0;
- fs.read((char*)& temp_size, sizeof(int));
- if (temp_size == 0)
- {
- throw exception("Error! You are not registered in the system!");
- }
- else
- {
- string temp_login = "";
- string temp_password = "";
- fs.read((char*)& temp_login, sizeof(string));
- fs.read((char*)& temp_password, sizeof(string));
- if (temp_login == login and temp_password == password)
- {
- m_login = login;
- m_password = login;
- }
- else
- {
- throw exception("Error! You entered incorrectly login or password!");
- }
- }
- }
- fs.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment