Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool authenticate(string user,string pass, MyForm form) {
- bool success = 0;
- ifstream file("authdata.txt");
- string fusername, fpassword;
- if (!file) {
- MessageBox::Show("No file");
- ofstream file("authdata.txt");
- file << "admin,admin,3;";
- }
- while (file) {
- ws(file);
- getline(file, fusername, ','); // use ; as delimiter
- getline(file, fpassword, ';');
- cout << fusername << " = " << user << "\n";
- cout << fpassword << " = " << pass << "\n";
- if (fusername == user & fpassword == pass) {
- cout << "logged";
- bool success = 1;
- form->Close();
- return success;
- }
- }
- if (success == 0) {
- MessageBox::Show("Usuario o contraseña incorrecta", "Ups...", MessageBoxButtons::OK, MessageBoxIcon::Error);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement