We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f4ed22e commit 6b23d3eCopy full SHA for 6b23d3e
src/libraries/Authentication.php
@@ -188,15 +188,24 @@ protected static function lookup(string $key) {
188
Common::$database = DatabaseDriver::getDatabaseObject();
189
}
190
191
+ $dt_now_str = (new DateTime(
192
+ 'now', new DateTimeZone('Etc/UTC')
193
+ ))->format(self::DATE_SQL);
194
+
195
$fingerprint = false;
196
197
try {
198
$stmt = Common::$database->prepare('
199
SELECT `user_id`, `ip_address`, `user_agent`
- 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;
205
');
206
207
$stmt->bindParam(':id', $key, PDO::PARAM_STR);
208
+ $stmt->bindParam(':dt', $dt_now_str, PDO::PARAM_STR);
209
210
$r = $stmt->execute();
211
0 commit comments