managers: refactor class member vars (#10242)
This commit is contained in:
parent
6f174a9e08
commit
ce821294e2
54 changed files with 930 additions and 932 deletions
|
|
@ -18,7 +18,7 @@ std::string CTokenManager::getRandomUUID() {
|
|||
uuid = std::format("{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}", (uint16_t)uuid_[0], (uint16_t)uuid_[1],
|
||||
(uint16_t)uuid_[2], (uint16_t)uuid_[3], (uint16_t)uuid_[4], (uint16_t)uuid_[5], (uint16_t)uuid_[6], (uint16_t)uuid_[7], (uint16_t)uuid_[8],
|
||||
(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));
|
||||
} while (m_tokens.contains(uuid));
|
||||
|
||||
return uuid;
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ std::string CTokenManager::getRandomUUID() {
|
|||
std::string CTokenManager::registerNewToken(std::any data, Time::steady_dur expires) {
|
||||
std::string uuid = getRandomUUID();
|
||||
|
||||
m_mTokens[uuid] = makeShared<CUUIDToken>(uuid, data, expires);
|
||||
m_tokens[uuid] = makeShared<CUUIDToken>(uuid, data, expires);
|
||||
return uuid;
|
||||
}
|
||||
|
||||
|
|
@ -34,16 +34,16 @@ SP<CUUIDToken> CTokenManager::getToken(const std::string& uuid) {
|
|||
|
||||
// cleanup expired tokens
|
||||
const auto NOW = Time::steadyNow();
|
||||
std::erase_if(m_mTokens, [&NOW](const auto& el) { return el.second->m_expiresAt < NOW; });
|
||||
std::erase_if(m_tokens, [&NOW](const auto& el) { return el.second->m_expiresAt < NOW; });
|
||||
|
||||
if (!m_mTokens.contains(uuid))
|
||||
if (!m_tokens.contains(uuid))
|
||||
return {};
|
||||
|
||||
return m_mTokens.at(uuid);
|
||||
return m_tokens.at(uuid);
|
||||
}
|
||||
|
||||
void CTokenManager::removeToken(SP<CUUIDToken> token) {
|
||||
if (!token)
|
||||
return;
|
||||
m_mTokens.erase(token->m_uuid);
|
||||
m_tokens.erase(token->m_uuid);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue