blob: 92638e9b9b944cc8ac5fb72e12a0fe4ad7209545 (
plain)
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
|
#pragma once
#include <chrono>
#include <any>
#include <unordered_map>
#include <string>
#include "../helpers/memory/Memory.hpp"
class CUUIDToken {
public:
CUUIDToken(const std::string& uuid_, std::any data_, std::chrono::steady_clock::duration expires);
std::string getUUID();
std::any data;
private:
std::string uuid;
std::chrono::steady_clock::time_point expiresAt;
friend class CTokenManager;
};
class CTokenManager {
public:
std::string registerNewToken(std::any data, std::chrono::steady_clock::duration expires);
std::string getRandomUUID();
SP<CUUIDToken> getToken(const std::string& uuid);
void removeToken(SP<CUUIDToken> token);
private:
std::unordered_map<std::string, SP<CUUIDToken>> m_mTokens;
};
inline std::unique_ptr<CTokenManager> g_pTokenManager;
|