From 360a494fd4f910c4cf88f4ffa2032ace51856c32 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Fri, 6 Jul 2018 14:38:08 +0200 Subject: [PATCH] Store login time of users after successful auth. --- weave_storage.php | 19 +++++++++++++++++++ weave_utils.php | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/weave_storage.php b/weave_storage.php index 87987f6..c3303ee 100644 --- a/weave_storage.php +++ b/weave_storage.php @@ -731,6 +731,25 @@ class WeaveStorage } return 1; } + + function store_user_login($username) + { + try + { + $update_statement = "update users set login = :logintime where username = :username"; + + $sth = $this->_dbh->prepare($update_statement); + $sth->bindParam(':username', $username); + $sth->bindParam(':logintime', time()); + $sth->execute(); + } + catch( PDOException $exception ) + { + log_error("update login:" . $exception->getMessage()); + return 0; + } + return 1; + } function create_user($username, $password) { diff --git a/weave_utils.php b/weave_utils.php index 5f5045c..586f38f 100644 --- a/weave_utils.php +++ b/weave_utils.php @@ -252,7 +252,8 @@ log_error($e->getMessage(), $e->getCode()); report_problem($e->getMessage(), $e->getCode()); } - + // Login success - record login time + $db->store_user_login($auth_user); return true; }