Added demo account support

This commit is contained in:
emeric
2018-08-01 12:57:03 +02:00
parent a31fb3c062
commit 4cadb915ba
11 changed files with 124 additions and 34 deletions
+12
View File
@@ -40,6 +40,18 @@ Auth::Auth()
// LoginName
setFormWidget(Wt::Auth::AuthModel::LoginNameField, std::make_unique<Wt::WLineEdit>());
{
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
auto demoUser = Database::User::getDemo(LmsApp->getDboSession());
if (demoUser)
{
Wt::Auth::User authUser = LmsApp->getDb().getUserDatabase().findWithId(std::to_string(demoUser.id()));
_model->setValue(Wt::Auth::AuthModel::LoginNameField, authUser.identity(Wt::Auth::Identity::LoginName));
_model->setValue(Wt::Auth::AuthModel::PasswordField, authUser.identity(Wt::Auth::Identity::LoginName));
}
}
// Password
auto password = std::make_unique<Wt::WLineEdit>();
password->setEchoMode(Wt::EchoMode::Password);