added CORS
This commit is contained in:
32
source/login/Session.hpp
Normal file
32
source/login/Session.hpp
Normal 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__
|
||||
Reference in New Issue
Block a user