Skip to content

Commit 6c9cb8a

Browse files
committed
refactor: use Time::now()
1 parent 0dd0562 commit 6c9cb8a

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/Authentication/Authenticators/Session.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -836,10 +836,9 @@ protected function rememberUser(User $user): void
836836

837837
private function calcExpires(): string
838838
{
839-
return date(
840-
'Y-m-d H:i:s',
841-
time() + setting('Auth.sessionConfig')['rememberLength']
842-
);
839+
$timestamp = Time::now()->getTimestamp() + setting('Auth.sessionConfig')['rememberLength'];
840+
841+
return Time::createFromTimestamp($timestamp)->format('Y-m-d H:i:s');
843842
}
844843

845844
private function setRememberMeCookie(string $rawToken): void

src/Models/LoginModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function recordLoginAttempt(
6161
'id_type' => $idType,
6262
'identifier' => $identifier,
6363
'user_id' => $userId,
64-
'date' => date('Y-m-d H:i:s'),
64+
'date' => Time::now()->format('Y-m-d H:i:s'),
6565
'success' => (int) $success,
6666
]);
6767

src/Models/UserIdentityModel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace CodeIgniter\Shield\Models;
44

5+
use CodeIgniter\I18n\Time;
56
use CodeIgniter\Model;
67
use CodeIgniter\Shield\Authentication\Authenticators\AccessTokens;
78
use CodeIgniter\Shield\Authentication\Authenticators\Session;
@@ -247,7 +248,7 @@ public function getIdentitiesByTypes(User $user, array $types): array
247248
*/
248249
public function touchIdentity(UserIdentity $identity): void
249250
{
250-
$identity->last_used_at = date('Y-m-d H:i:s');
251+
$identity->last_used_at = Time::now()->format('Y-m-d H:i:s');
251252

252253
$return = $this->save($identity);
253254

0 commit comments

Comments
 (0)