Advertisement
tmax

Untitled

Feb 7th, 2016
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. bool authenticate(string user,string pass, MyForm form) {
  2. bool success = 0;
  3. ifstream file("authdata.txt");
  4. string fusername, fpassword;
  5.  
  6. if (!file) {
  7. MessageBox::Show("No file");
  8. ofstream file("authdata.txt");
  9. file << "admin,admin,3;";
  10. }
  11.  
  12.  
  13. while (file) {
  14. ws(file);
  15. getline(file, fusername, ','); // use ; as delimiter
  16. getline(file, fpassword, ';');
  17.  
  18. cout << fusername << " = " << user << "\n";
  19. cout << fpassword << " = " << pass << "\n";
  20.  
  21. if (fusername == user & fpassword == pass) {
  22. cout << "logged";
  23. bool success = 1;
  24. form->Close();
  25.  
  26. return success;
  27. }
  28. }
  29.  
  30. if (success == 0) {
  31. MessageBox::Show("Usuario o contraseña incorrecta", "Ups...", MessageBoxButtons::OK, MessageBoxIcon::Error);
  32. }
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement