39 lines
964 B
C++
39 lines
964 B
C++
#include "Session.h"
|
|
#include <Wt/Auth/Dbo/UserDatabase.h>
|
|
|
|
Session::Session(Wt::Dbo::SqlConnectionPool &connectionPool) {
|
|
setConnectionPool(connectionPool);
|
|
|
|
mapClass<Task>("task");
|
|
mapClass<HomeBox::Item>("homebox_item");
|
|
|
|
mapClass<User>("user");
|
|
mapClass<AuthInfo>("auth_info");
|
|
mapClass<AuthInfo::AuthIdentityType>("auth_identity");
|
|
mapClass<AuthInfo::AuthTokenType>("auth_token");
|
|
|
|
m_users = std::make_unique<UserDatabase>(*this);
|
|
}
|
|
|
|
Session::~Session() {
|
|
}
|
|
|
|
Wt::Dbo::ptr<User> Session::user() const {
|
|
if (m_login.loggedIn()) {
|
|
Wt::Dbo::ptr<AuthInfo> authInfo = m_users->find(m_login.user());
|
|
return authInfo->user();
|
|
} else
|
|
return Wt::Dbo::ptr<User>();
|
|
}
|
|
|
|
Wt::Auth::AbstractUserDatabase &Session::users() {
|
|
return *m_users;
|
|
}
|
|
|
|
Wt::Auth::Login &Session::login() {
|
|
return m_login;
|
|
}
|
|
|
|
DBO_INSTANTIATE_TEMPLATES(User)
|
|
DBO_INSTANTIATE_TEMPLATES(Task)
|
|
DBO_INSTANTIATE_TEMPLATES(HomeBox::Item) |