From 1186b7a43945c9ed34ceb690e0a80db2176a9f2c Mon Sep 17 00:00:00 2001 From: Kevin Whitaker Date: Sat, 18 Feb 2017 14:39:16 -0500 Subject: [PATCH] Mark a user logged in in DB when successful. --- src/ui/LoginInterface.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ui/LoginInterface.cpp b/src/ui/LoginInterface.cpp index 97b811b..8fa7126 100644 --- a/src/ui/LoginInterface.cpp +++ b/src/ui/LoginInterface.cpp @@ -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().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 -- GitLab