Mark a user logged in in DB when successful.

This commit is contained in:
Kevin Whitaker
2017-02-18 14:39:16 -05:00
parent cb393b0c0d
commit 1186b7a439

View File

@@ -106,6 +106,14 @@ void LoginInterface::loginCheck()
Wt::log("info") << "login by "<< app->currentUser.username << " happened.";
setLocalCookieForUser(app->currentUser);
app->loginCompleted();
//Now mark this as a successful login.
Wt::Dbo::Transaction loginTransaction(sqlSession);
UserAction* action = new UserAction();
action->action = UserAction::UAction::Login;
action->user = sqlSession.find<User>().where("username = ?").bind(app->currentUser.username);
action->datetime = Wt::WDateTime::currentDateTime();
sqlSession.add(action);
loginTransaction.commit();
}
//If credentials don't match, reject user with message saying crednetials are wrong and they can ask an admin to make them an account.
else