Make the remember-me feature make again

This commit is contained in:
emeric
2018-04-19 13:47:45 +02:00
parent 3b83b37c38
commit a30938a7f9
2 changed files with 10 additions and 7 deletions
+7 -4
View File
@@ -58,11 +58,14 @@ Auth::Auth()
this->setHidden(true); 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()); 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 void
+3 -3
View File
@@ -119,7 +119,7 @@ LmsApplication::LmsApplication(const Wt::WEnvironment& env, Wt::Dbo::SqlConnecti
firstConnection = (Database::User::getAll(LmsApp->getDboSession()).size() == 0); 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) if (firstConnection)
{ {
@@ -127,8 +127,6 @@ LmsApplication::LmsApplication(const Wt::WEnvironment& env, Wt::Dbo::SqlConnecti
} }
else else
{ {
_auth = root()->addNew<Auth>();
LmsApp->getDb().getLogin().changed().connect(std::bind([=] LmsApp->getDb().getLogin().changed().connect(std::bind([=]
{ {
try try
@@ -141,6 +139,8 @@ LmsApplication::LmsApplication(const Wt::WEnvironment& env, Wt::Dbo::SqlConnecti
throw std::runtime_error("Internal error"); throw std::runtime_error("Internal error");
} }
})); }));
_auth = root()->addNew<Auth>();
} }
} }