added CORS

This commit is contained in:
2026-02-16 23:24:31 +01:00
parent 14b8234e77
commit 58d37b51b7
27 changed files with 80 additions and 32 deletions

32
source/login/Session.hpp Normal file
View File

@@ -0,0 +1,32 @@
#ifndef __SESSION_H__
#define __SESSION_H__
#include <chrono>
namespace login {
class Session {
public:
static constexpr auto SESSION_LIFETIME = std::chrono::minutes(30);
static constexpr size_t SESSION_ID_SIZE = 32;
Session(int userId);
// extend the session lifetime
void extend();
void extend(std::chrono::time_point<std::chrono::steady_clock> now);
bool isExpired(std::chrono::time_point<std::chrono::steady_clock> now);
const int userId() { return m_userId; }
const std::chrono::steady_clock::time_point expiresAt() {return m_expiresAt;}
private:
const int m_userId;
std::chrono::steady_clock::time_point m_expiresAt;
};
}
#endif // __SESSION_H__