Skip to content

Commit 6b23d3e

Browse files
committed
Enforce user session expiration
1 parent f4ed22e commit 6b23d3e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/libraries/Authentication.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,24 @@ protected static function lookup(string $key) {
188188
Common::$database = DatabaseDriver::getDatabaseObject();
189189
}
190190

191+
$dt_now_str = (new DateTime(
192+
'now', new DateTimeZone('Etc/UTC')
193+
))->format(self::DATE_SQL);
194+
191195
$fingerprint = false;
192196

193197
try {
194198
$stmt = Common::$database->prepare('
195199
SELECT `user_id`, `ip_address`, `user_agent`
196-
FROM `user_sessions` WHERE `id` = :id LIMIT 1;
200+
FROM `user_sessions`
201+
WHERE `id` = :id AND (
202+
`expires_datetime` = NULL OR
203+
:dt < `expires_datetime`
204+
) LIMIT 1;
197205
');
198206

199207
$stmt->bindParam(':id', $key, PDO::PARAM_STR);
208+
$stmt->bindParam(':dt', $dt_now_str, PDO::PARAM_STR);
200209

201210
$r = $stmt->execute();
202211

0 commit comments

Comments
 (0)