#include "Session.h" #include #include Session::Session(Wt::Dbo::SqlConnectionPool &connectionPool) { setConnectionPool(connectionPool); mapClass("task"); mapClass("homebox_item"); mapClass("visitor_record"); mapClass("user"); mapClass("auth_info"); mapClass("auth_identity"); mapClass("auth_token"); m_users = std::make_unique(*this); } Session::~Session() { } Wt::Dbo::ptr Session::user() const { if (m_login.loggedIn()) { Wt::Dbo::ptr authInfo = m_users->find(m_login.user()); return authInfo->user(); } else return Wt::Dbo::ptr(); } Wt::Auth::AbstractUserDatabase &Session::users() { return *m_users; } Wt::Auth::Login &Session::login() { return m_login; } namespace Wt { namespace Dbo { template <> void JsonSerializer::act(FieldRef field) { using namespace std::chrono; writeFieldName(field.name()); fastJsStringLiteral(std::to_string(duration_cast(field.value().time_since_epoch()).count())); } } // namespace Dbo } // namespace Wt DBO_INSTANTIATE_TEMPLATES(User) DBO_INSTANTIATE_TEMPLATES(Task) DBO_INSTANTIATE_TEMPLATES(HomeBox::Item) DBO_INSTANTIATE_TEMPLATES(VisitorRecord)