#include "Session.h" #include "BoostLog.h" #include #include #include #include #include #include #include #include #include Session::Session(Wt::Dbo::SqlConnectionPool &connectionPool) : m_connectionPool(connectionPool) { setConnectionPool(m_connectionPool); mapClass("user"); mapClass("auth_info"); mapClass("auth_identity"); mapClass("auth_token"); try { createTables(); LOG(info) << "Created database."; } catch (Wt::Dbo::Exception &e) { LOG(error) << e.what() << ", using existing database"; } 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; }