added CORS
This commit is contained in:
33
source/login/SessionHandler.hpp
Normal file
33
source/login/SessionHandler.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef __SESSIONHANDLER_H__
|
||||
#define __SESSIONHANDLER_H__
|
||||
|
||||
#include "Session.hpp"
|
||||
#include <optional>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
||||
namespace login {
|
||||
|
||||
class SessionHandler {
|
||||
|
||||
public:
|
||||
SessionHandler();
|
||||
~SessionHandler();
|
||||
|
||||
std::optional<std::string> createSession(int userId);
|
||||
|
||||
// return the user id if the user is logged in
|
||||
std::optional<int> isSessionValid(const std::string& sessionId);
|
||||
private:
|
||||
void cleanupWorker();
|
||||
std::thread cleanupThread;
|
||||
std::atomic<bool> stopCleanupThread;
|
||||
std::mutex sessionMutex;
|
||||
|
||||
std::unordered_map<std::string, Session> sessions;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __SESSIONHANDLER_H__
|
||||
Reference in New Issue
Block a user