Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. struct AuthenticationBackend {
  2.   virtual User Authenticate(const std::string& user, const std:string& pass) = 0;
  3. }
  4.  
  5. struct MySQLAuthenticationBackend {
  6.   virtual User* Authenticate(const std::string& userName, const std:string& pass)
  7.   {
  8.     Result result = externalDBConnection->Query("SELECT user, pass FROM accounts WHERE user=? AND pass=HASH(?)", userName, pass);
  9.     if (result->Size() == 1)
  10.     {
  11.       if (psEngine->HasUser(userName))
  12.       {
  13.          return psEngine->GetUser(userName);
  14.       }
  15.       else
  16.       {
  17.          return psEngine->CreateUser(userName, pass);
  18.       }
  19.      
  20.     }
  21.     return 0;
  22.   }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement