mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 20:05:58 +01:00
tokenmgr: separate getRandomUUID from registerNewToken
This commit is contained in:
parent
2e763764bf
commit
82a6fba6ec
2 changed files with 8 additions and 1 deletions
|
@ -10,7 +10,7 @@ std::string CUUIDToken::getUUID() {
|
|||
return uuid;
|
||||
}
|
||||
|
||||
std::string CTokenManager::registerNewToken(std::any data, std::chrono::system_clock::duration expires) {
|
||||
std::string CTokenManager::getRandomUUID() {
|
||||
std::string uuid;
|
||||
do {
|
||||
uuid_t uuid_;
|
||||
|
@ -20,6 +20,12 @@ std::string CTokenManager::registerNewToken(std::any data, std::chrono::system_c
|
|||
(uint16_t)uuid_[9], (uint16_t)uuid_[10], (uint16_t)uuid_[11], (uint16_t)uuid_[12], (uint16_t)uuid_[13], (uint16_t)uuid_[14], (uint16_t)uuid_[15]);
|
||||
} while (m_mTokens.contains(uuid));
|
||||
|
||||
return uuid;
|
||||
}
|
||||
|
||||
std::string CTokenManager::registerNewToken(std::any data, std::chrono::system_clock::duration expires) {
|
||||
std::string uuid = getRandomUUID();
|
||||
|
||||
m_mTokens[uuid] = std::make_shared<CUUIDToken>(uuid, data, expires);
|
||||
return uuid;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ class CUUIDToken {
|
|||
class CTokenManager {
|
||||
public:
|
||||
std::string registerNewToken(std::any data, std::chrono::system_clock::duration expires);
|
||||
std::string getRandomUUID();
|
||||
|
||||
std::shared_ptr<CUUIDToken> getToken(const std::string& uuid);
|
||||
void removeToken(std::shared_ptr<CUUIDToken> token);
|
||||
|
|
Loading…
Reference in a new issue