-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuth.h
More file actions
52 lines (43 loc) · 1.64 KB
/
Auth.h
File metadata and controls
52 lines (43 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef AUTH_H
#define AUTH_H
#include <string>
#include "HashTable.h"
struct MatchHistory {
char opponent[32];
bool win;
int score;
long timestamp;
};
class Auth {
private:
HashTable* userTable; // Hash table to store user credentials
std::string currentUser; // Currently logged in user
bool isLoggedIn;
// Helper functions
bool validatePassword(const std::string& password);
bool validateUsername(const std::string& username);
std::string hashPassword(const std::string& password);
void saveToFile();
void loadFromFile();
public:
// Constructor and Destructor
Auth();
~Auth();
// Authentication methods
bool registerUser(const std::string& username, const std::string& password);
bool login(const std::string& username, const std::string& password);
void logout();
bool isUserLoggedIn() const;
std::string getCurrentUser() const;
// Player stats and friends methods
int getPlayerWins(const std::string& username);
int getPlayerLosses(const std::string& username);
int getPlayerPoints(const std::string& username);
int getPlayerScore(const std::string& username); // Get player's current score
int getRecentMatches(const std::string& username, MatchHistory* matches, int maxCount);
int getFriendsList(const std::string& username, char friendsList[][32], int maxCount);
// Profile management
bool updateProfile(const std::string& username, const std::string& field, const std::string& value);
bool deleteAccount(const std::string& username, const std::string& password);
};
#endif // AUTH_H