Skip to content

Commit 217d2c0

Browse files
committed
fix file
1 parent 1d8b26b commit 217d2c0

File tree

1 file changed

+0
-43
lines changed

1 file changed

+0
-43
lines changed

src/Models/UserIdentityModel.php

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
use CodeIgniter\Shield\Entities\UserIdentity;
2525
use CodeIgniter\Shield\Exceptions\LogicException;
2626
use CodeIgniter\Shield\Exceptions\ValidationException;
27-
use DateInterval;
28-
use DateTime;
2927
use Exception;
3028
use Faker\Generator;
3129
use InvalidArgumentException;
@@ -104,39 +102,6 @@ private function checkUserId(User $user): void
104102
}
105103
}
106104

107-
private function checkExpiresAtFormat(string $expiresAt): string
108-
{
109-
$expireMatch = [];
110-
111-
// Check Y-m-d h:i:s format.
112-
preg_match('/\d{4}-\d{2}-\d{2}.\d{2}:\d{2}:\d{2}/', $expiresAt, $expireMatch, PREG_UNMATCHED_AS_NULL);
113-
114-
// Format Y-m-d h:i:s not found.
115-
if ($expireMatch === []) {
116-
// Looking for relative format like 1 day, 2 weeks and process all
117-
preg_match_all('/[1].(second|minute|hour|day|week|month|year)|[2,3,4,5,6,7,8,9].(seconds|minutes|hours|days|weeks|months|years)/', $expiresAt, $expireMatch, PREG_PATTERN_ORDER);
118-
119-
if ($expireMatch[0] !== []) {
120-
// Dummy DateTime to add() DateInterval
121-
$dateTime = new DateTime();
122-
123-
// Turn the preg_match array into string splitted by ' + '
124-
// to be fed into DateTime->add() to generate new date
125-
$relativeTime = implode(' + ', $expireMatch[0]);
126-
127-
// add relative formats
128-
$dateTime->add(DateInterval::createFromDateString($relativeTime));
129-
130-
// return Dummy DateTime
131-
return $dateTime->format('Y-m-d h:i:s');
132-
}
133-
134-
throw new InvalidArgumentException('$expiresAt should be a DateTime string formatted as "Y-m-d h:i:s" or a DateTime relative formats.');
135-
}
136-
137-
return $expiresAt;
138-
}
139-
140105
/**
141106
* Create an identity with 6 digits code for auth action
142107
*
@@ -190,10 +155,6 @@ public function generateAccessToken(User $user, string $name, array $scopes = ['
190155
{
191156
$this->checkUserId($user);
192157

193-
// if ($expiresAt !== null && $expiresAt !== '' && $expiresAt !== '0') {
194-
// $expiresAt = $this->checkExpiresAtFormat($expiresAt);
195-
// }
196-
197158
helper('text');
198159

199160
$return = $this->insert([
@@ -320,10 +281,6 @@ public function generateHmacToken(User $user, string $name, array $scopes = ['*'
320281
{
321282
$this->checkUserId($user);
322283

323-
// if ($expiresAt !== null && $expiresAt !== '' && $expiresAt !== '0') {
324-
// $expiresAt = $this->checkExpiresAtFormat($expiresAt);
325-
// }
326-
327284
$encrypter = new HmacEncrypter();
328285
$rawSecretKey = $encrypter->generateSecretKey();
329286
$secretKey = $encrypter->encrypt($rawSecretKey);

0 commit comments

Comments
 (0)