diff --git a/src/libs/db/postgresql_connector/src/config.cpp b/src/libs/db/postgresql_connector/src/config.cpp
index 73dc8f4..c918ff8 100644
--- a/src/libs/db/postgresql_connector/src/config.cpp
+++ b/src/libs/db/postgresql_connector/src/config.cpp
@@ -11,7 +11,7 @@ Config::Config() {
password = "postgres";
dbname = "postgres";
port = 5432;
- debug = true;
+ debug = false;
}
Config::Config(std::function< bool(const std::string &, std::string &) > readProperty) {
@@ -44,6 +44,6 @@ Config::Config(std::function< bool(const std::string &, std::string &) > readPro
readString("db_password", password, "postgres");
readString("db_name", dbname, "postgres");
readInt("db_port", port, 5432u);
- readBool("db_debug", debug, true);
+ readBool("db_debug", debug, false);
}
} // namespace eedb::db
diff --git a/src/libs/webapp/CMakeLists.txt b/src/libs/webapp/CMakeLists.txt
index 5642df4..4954316 100644
--- a/src/libs/webapp/CMakeLists.txt
+++ b/src/libs/webapp/CMakeLists.txt
@@ -1,9 +1,13 @@
set(LIB webapp)
file(GLOB_RECURSE ${LIB}_SOURCE src/*)
+file(GLOB ${LIB}_CONFIG config/*)
+
+set(CONFIG )
+configure_file(config/wt_config_${CMAKE_BUILD_TYPE}.xml ${CMAKE_BINARY_DIR}/local/etc/wt/wt_config.xml COPYONLY)
# find packages
-find_package(wt)
+find_package(wt REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
@@ -17,7 +21,7 @@ else (CMAKE_BUILD_TYPE STREQUAL "Release")
endif()
# create library
-add_library(${LIB} ${${LIB}_SOURCE})
+add_library(${LIB} ${${LIB}_SOURCE} ${${LIB}_CONFIG})
# link all
target_include_directories(${LIB}
diff --git a/src/libs/webapp/config/wt_config_Debug.xml b/src/libs/webapp/config/wt_config_Debug.xml
new file mode 100644
index 0000000..b4d1238
--- /dev/null
+++ b/src/libs/webapp/config/wt_config_Debug.xml
@@ -0,0 +1,658 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+ URL
+
+
+ false
+
+
+ 600
+
+
+ 50
+
+
+
+
+
+
+
+
+ /home/bwieczor/src/build-eedb-Desktop_GCC_7-Debug/local/var/run/wt
+
+
+
+
+
+
+
+ 128
+
+
+
+ false
+
+
+
+
+
+ -*
+
+
+ 128
+
+
+ 5120
+
+
+ 10
+
+
+ 13
+
+
+ 1
+
+
+ false
+
+
+ false
+
+
+ true
+
+
+ true
+
+
+ Load basic HTML
+
+
+ false
+
+
+ true
+
+
+ 500
+
+
+ 200
+
+
+
+
+
+
+
+
+ .*Googlebot.*
+ .*msnbot.*
+ .*Slurp.*
+ .*Crawler.*
+ .*Bot.*
+ .*ia_archiver.*
+ .*Twiceler.*
+
+
+
+
+
+
+ false
+
+
+ false
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ resources/
+
+
+ ext/
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/libs/webapp/config/wt_config_Release.xml b/src/libs/webapp/config/wt_config_Release.xml
new file mode 100644
index 0000000..67ef94e
--- /dev/null
+++ b/src/libs/webapp/config/wt_config_Release.xml
@@ -0,0 +1,658 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+ URL
+
+
+ false
+
+
+ 600
+
+
+ 50
+
+
+
+
+
+
+
+
+ /home/bwieczor/src/build-eedb-Desktop_GCC_7-Debug/local/var/run/wt
+
+
+
+
+
+
+
+ 128
+
+
+
+ false
+
+
+
+
+
+ -*
+
+
+ 128
+
+
+ 5120
+
+
+ 10
+
+
+ 13
+
+
+ 1
+
+
+ false
+
+
+ false
+
+
+ true
+
+
+ true
+
+
+ Load basic HTML
+
+
+ false
+
+
+ true
+
+
+ 500
+
+
+ 200
+
+
+
+
+
+
+
+
+ .*Googlebot.*
+ .*msnbot.*
+ .*Slurp.*
+ .*Crawler.*
+ .*Bot.*
+ .*ia_archiver.*
+ .*Twiceler.*
+
+
+
+
+
+
+ false
+
+
+ false
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ resources/
+
+
+ ext/
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/libs/webapp/include/eedb/WebApplication.hpp b/src/libs/webapp/include/eedb/WebApplication.hpp
index 832820b..cc69b15 100644
--- a/src/libs/webapp/include/eedb/WebApplication.hpp
+++ b/src/libs/webapp/include/eedb/WebApplication.hpp
@@ -15,13 +15,13 @@ class HomePage;
class IWebSession;
using AuthPageFactory = std::function< std::unique_ptr< AuthPage >() >;
-using HomePageFactory = std::function< std::unique_ptr< HomePage >(Wt::Auth::AuthWidget&) >;
+using HomePageFactory = std::function< std::unique_ptr< HomePage >(Wt::Auth::AuthWidget &) >;
class WebApplication : public Wt::WApplication {
public:
enum class LoginState { weak, strong };
WebApplication(std::unique_ptr< eedb::IWebSession > session, AuthPageFactory authPageFactory, HomePageFactory homePageFactory);
-~WebApplication(){}
+ ~WebApplication() {}
void authEventLogin(LoginState state);
void authEventLogout();
diff --git a/src/libs/webapp/include/eedb/WebServer.hpp b/src/libs/webapp/include/eedb/WebServer.hpp
index a016bc5..d7de79c 100644
--- a/src/libs/webapp/include/eedb/WebServer.hpp
+++ b/src/libs/webapp/include/eedb/WebServer.hpp
@@ -11,6 +11,8 @@ class WServer;
} // namespace Wt
namespace eedb {
+
+
class WebServer {
public:
using AppCreator = std::function< std::unique_ptr< Wt::WApplication >(const Wt::WEnvironment &) >;
diff --git a/src/libs/webapp/src/DefaultAuthPage.cpp b/src/libs/webapp/src/DefaultAuthPage.cpp
index 5f1778b..12a1c39 100644
--- a/src/libs/webapp/src/DefaultAuthPage.cpp
+++ b/src/libs/webapp/src/DefaultAuthPage.cpp
@@ -10,20 +10,13 @@
namespace eedb {
struct DefaultAuthPage::DefaultAuthPagePriv {
- DefaultAuthPagePriv(Wt::Auth::AuthWidget * widget, std::unique_ptr< Wt::Auth::AbstractUserDatabase > userDatabase)
- : _authWidget{widget}, _userDatabase{std::move(userDatabase)} {
- _authWidget->model()->addPasswordAuth(eedb::auth::Services::passwordService());
- _authWidget->model()->addOAuth(eedb::auth::Services::oAuthServices());
- _authWidget->setRegistrationEnabled(true);
- _authWidget->setId("eedb.authWidget");
- }
+ DefaultAuthPagePriv(std::unique_ptr< Wt::Auth::AbstractUserDatabase > userDatabase) : _userDatabase{std::move(userDatabase)} {}
Wt::Signal<> _onNeedEmailVerification;
Wt::Signal<> _onUserWeakLogin;
Wt::Signal<> _onUserStrongLogin;
Wt::Signal<> _onUserLogout;
- Wt::Auth::AuthWidget * _authWidget;
std::unique_ptr< Wt::Auth::AbstractUserDatabase > _userDatabase;
};
@@ -31,7 +24,12 @@ DefaultAuthPage::DefaultAuthPage(const auth::Services & baseAuth,
std::unique_ptr< Wt::Auth::AbstractUserDatabase > userDatabase,
Wt::Auth::Login & _login)
: AuthPage(*baseAuth.authService(), *userDatabase, _login),
- _priv{spimpl::make_unique_impl< DefaultAuthPagePriv >(this, std::move(userDatabase))} {
+ _priv{spimpl::make_unique_impl< DefaultAuthPagePriv >(std::move(userDatabase))} {
+ model()->addPasswordAuth(eedb::auth::Services::passwordService());
+ model()->addOAuth(eedb::auth::Services::oAuthServices());
+ setRegistrationEnabled(true);
+ setId("eedb.authWidget");
+
login().changed().connect([this]() {
if(login().state() == Wt::Auth::LoginState::Strong) {
_priv->_onUserStrongLogin.emit();
diff --git a/src/libs/webapp/src/WebApplication.cpp b/src/libs/webapp/src/WebApplication.cpp
index d215132..9fad787 100644
--- a/src/libs/webapp/src/WebApplication.cpp
+++ b/src/libs/webapp/src/WebApplication.cpp
@@ -46,26 +46,23 @@ WebApplication::WebApplication(std::unique_ptr< eedb::IWebSession > session,
authPage->registerOnUserWeakLogin([=] { authEventLogin(LoginState::weak); });
authPage->registerOnUserStrongLogin([=] { authEventLogin(LoginState::strong); });
authPage->registerOnUserLogout([=] { authEventLogout(); });
- authPage->processEnvironment();
-
- root()->addWidget(std::move(authPage));
+ root()->addWidget(std::move(authPage))->processEnvironment();
}
-void WebApplication::authEventLogin(WebApplication::LoginState state ) {
- if(state == WebApplication::LoginState::strong) {
- if(!_authWidget) {
- _authWidget = std::unique_ptr< Wt::Auth::AuthWidget >(
- dynamic_cast< Wt::Auth::AuthWidget * >(root()->removeWidget(root()->findById("eedb.authWidget")).release()));
- _authWidget->hide();
- }
- root()->clear();
- root()->removeStyleClass("container");
- root()->addWidget(_homePageFactory(*_authWidget));
+void WebApplication::authEventLogin(WebApplication::LoginState) {
+ if(!_authWidget) {
+ _authWidget = std::unique_ptr< Wt::Auth::AuthWidget >(
+ dynamic_cast< Wt::Auth::AuthWidget * >(root()->removeWidget(root()->findById("eedb.authWidget")).release()));
+ _authWidget->hide();
}
+ root()->clear();
+ root()->removeStyleClass("container");
+ root()->addWidget(_homePageFactory(*_authWidget));
}
void WebApplication::authEventLogout() {
redirect(url());
quit();
}
+
} // namespace eedb