Older/WebApplication/Session.cpp
luocai a9640bbda5
All checks were successful
Deploy Docker Images / Build dockerfile and Server deploy (push) Successful in 17s
Deploy / Build (push) Successful in 3m11s
remove blog example source.
2024-11-11 19:21:48 +08:00

44 lines
1.2 KiB
C++

#include "Session.h"
#include "BoostLog.h"
#include <Wt/Auth/Dbo/AuthInfo.h>
#include <Wt/Auth/Dbo/UserDatabase.h>
#include <Wt/Auth/FacebookService.h>
#include <Wt/Auth/GoogleService.h>
#include <Wt/Auth/HashFunction.h>
#include <Wt/Auth/PasswordService.h>
#include <Wt/Auth/PasswordStrengthValidator.h>
#include <Wt/Auth/PasswordVerifier.h>
#include <Wt/Dbo/backend/Sqlite3.h>
Session::Session(const std::string &sqliteDb) {
auto connection = std::make_unique<Wt::Dbo::backend::Sqlite3>(sqliteDb);
connection->setProperty("show-queries", "true");
setConnection(std::move(connection));
mapClass<User>("user");
mapClass<AuthInfo>("auth_info");
mapClass<AuthInfo::AuthIdentityType>("auth_identity");
mapClass<AuthInfo::AuthTokenType>("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<UserDatabase>(*this);
}
Session::~Session() {
}
Wt::Auth::AbstractUserDatabase &Session::users() {
return *m_users;
}
Wt::Auth::Login &Session::login() {
return m_login;
}