Skip to content

Commit 79856c3

Browse files
committed
Admin: Security: Fix issue when date field is not complete (unknown historical reason) - refs BT#21146 #4960
1 parent a1052bd commit 79856c3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

main/inc/lib/usermanager.lib.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7736,19 +7736,20 @@ public static function redirectToResetPassword($userId)
77367736
);
77377737

77387738
if (empty($lastUpdate) or empty($lastUpdate['password_updated_at'])) {
7739-
error_log('No password_updated_at');
77407739
$userObj = api_get_user_entity($userId);
77417740
$registrationDate = $userObj->getRegistrationDate();
77427741
$now = new \DateTime(null, new DateTimeZone('UTC'));
77437742
$interval = $now->diff($registrationDate);
77447743
$daysSince = $interval->format('%a');
7745-
error_log('Days since registration: '.$daysSince);
77467744
if ($daysSince > $forceRotateDays) {
7747-
error_log('We need to force reset');
77487745
$forceRotate = true;
77497746
}
77507747
} else {
77517748
$now = new \DateTime(null, new DateTimeZone('UTC'));
7749+
// In some cases, old records might contain an incomplete Y-m-d H:i:s format
7750+
if (strlen($lastUpdate['password_updated_at']) == 16) {
7751+
$lastUpdate['password_updated_at'] .= ':00';
7752+
}
77527753
$date = \DateTime::createFromFormat('Y-m-d H:i:s', $lastUpdate['password_updated_at'], new DateTimeZone('UTC'));
77537754
$interval = $now->diff($date);
77547755
$daysSince = $interval->format('%a');

0 commit comments

Comments
 (0)