/
Shymer123
/
LumenServer
Обзор
Документация
Войти
/
Shymer123
/
LumenServer
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Server/SourceFiles/Services/TokenService.h
44 строки
2 KB
Shymer123
Initial commit: LumenServer
20 июн 2026, 12:43
20 июн 2026, 12:43
173f14c
Код
Авторство
О чём код?
#ifndef TOKENSERVICE_H #define TOKENSERVICE_H #include <string> #include <optional> #include "Core/Settings/SecuritySettings.h" #include "Storage/Db/Repositories/SessionRepository.h" namespace Services { struct Tokens { std::string access_token; std::string refresh_token; std::string device_id; }; class TokenService { public: explicit TokenService(Storage::Db::Repositories::SessionRepository& sessionRepo, const Core::Settings::SecuritySettings& securitySettings); Tokens generateTokens(const std::string& userId, const std::string& deviceId = ""); std::optional<Tokens> refreshTokens(const std::string& refreshToken, const std::string& deviceId); bool revokeRefreshToken(const std::string& refreshToken); bool revokeUserDeviceSession(const std::string& userId, const std::string& deviceId); std::optional<std::string> validateAccessToken(const std::string& token); std::optional<Storage::Db::Repositories::SessionRecord> getSessionByRefreshToken(const std::string& refreshToken); std::optional<std::string> getUserIdFromToken(const std::string& token); std::vector<Storage::Db::Repositories::SessionRecord> getUserSessions(const std::string& userId); bool updateLastActivity(const std::string& userId, const std::string& deviceId); private: Storage::Db::Repositories::SessionRepository& m_sessionRepo; const Core::Settings::SecuritySettings& m_securitySettings; std::string generateDeviceInfo(); }; } // namespace Services #endif // TOKENSERVICE_H