12#include <unordered_map>
13#include <unordered_set>
30 explicit AuthService(
const std::string &accountsFile);
39 bool authenticate(
const std::string &username,
const std::string &password)
override;
74 bool registerUser(
const std::string &username,
const std::string &password);
std::unordered_map< std::string, AccountData > _accounts
Map of username to account data.
std::unique_ptr< IPasswordHasher > _passwordHasher
Password hashing implementation.
bool validateToken(const std::string &token)
Validate a token.
bool getAutoMatchmaking(const std::string &username) const
Get auto-matchmaking preference for a user.
std::unordered_map< std::string, std::string > _activeTokens
Map of tokens to usernames.
void loadAccounts()
Load user accounts from JSON file.
std::unordered_set< std::string > _authenticatedUsers
Set of authenticated usernames.
static constexpr uint64_t SAVE_INTERVAL_SECONDS
Save every 60 seconds.
bool isUserAuthenticated(const std::string &username) const
Check if a user is authenticated.
std::string generateToken(const std::string &username)
Generate an authentication token for a user.
bool registerUser(const std::string &username, const std::string &password)
Register a new user account.
void saveAccounts()
Save user accounts to JSON file.
uint64_t _lastSaveTime
Timestamp of last save.
std::string _accountsFile
JSON file to store accounts.
bool _accountsDirty
Flag indicating unsaved changes.
bool updateAutoMatchmaking(const std::string &username, bool enabled)
Update auto-matchmaking preference for a user.
bool authenticate(const std::string &username, const std::string &password) override
Authenticate a user with username and password.
void revokeToken(const std::string &token)
Revoke a token.