From a30938a7f93ba6d6bbe0fc860c61e77ed2f156dd Mon Sep 17 00:00:00 2001 From: emeric Date: Thu, 19 Apr 2018 13:47:45 +0200 Subject: [PATCH] Make the remember-me feature make again --- src/ui/Auth.cpp | 11 +++++++---- src/ui/LmsApplication.cpp | 6 +++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/ui/Auth.cpp b/src/ui/Auth.cpp index 961d2fb4..ff1d39da 100644 --- a/src/ui/Auth.cpp +++ b/src/ui/Auth.cpp @@ -58,11 +58,14 @@ Auth::Auth() this->setHidden(true); })); -// Wt::Auth::User user = _model->processAuthToken(); -// if (user.isValid()) -// _model->loginUser(LmsApp->getDb().getLogin(), user, Wt::Auth::LoginState::Weak); - updateView(_model.get()); + + Wt::Auth::User user = _model->processAuthToken(); + if (user.isValid()) + { + LMS_LOG(UI, DEBUG) << "Valid user found from auth token (id = " << user.id() << ")"; + _model->loginUser(LmsApp->getDb().getLogin(), user, Wt::Auth::LoginState::Weak); + } } void diff --git a/src/ui/LmsApplication.cpp b/src/ui/LmsApplication.cpp index ed59d298..f2d302e3 100644 --- a/src/ui/LmsApplication.cpp +++ b/src/ui/LmsApplication.cpp @@ -119,7 +119,7 @@ LmsApplication::LmsApplication(const Wt::WEnvironment& env, Wt::Dbo::SqlConnecti firstConnection = (Database::User::getAll(LmsApp->getDboSession()).size() == 0); } - LMS_LOG(UI, DEBUG) << "Creating root widget. First connection = " << std::boolalpha << firstConnection; + LMS_LOG(UI, DEBUG) << "Creating root widget. First connection = " << firstConnection; if (firstConnection) { @@ -127,8 +127,6 @@ LmsApplication::LmsApplication(const Wt::WEnvironment& env, Wt::Dbo::SqlConnecti } else { - _auth = root()->addNew(); - LmsApp->getDb().getLogin().changed().connect(std::bind([=] { try @@ -141,6 +139,8 @@ LmsApplication::LmsApplication(const Wt::WEnvironment& env, Wt::Dbo::SqlConnecti throw std::runtime_error("Internal error"); } })); + + _auth = root()->addNew(); } }