Skip to content

Commit

Permalink
Merge pull request #19 from ichtrojan/support
Browse files Browse the repository at this point in the history
v1.4.2
  • Loading branch information
ichtrojan authored Sep 16, 2023
2 parents 3fe67df + 0f25de1 commit ff8353d
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/Otp.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,7 @@ public function generate(string $identifier, int $digits = 4, int $validity = 10
{
Model::where('identifier', $identifier)->where('valid', true)->delete();

$token = str_pad($this->generatePin(), 4, '0', STR_PAD_LEFT);

if ($digits == 5)
$token = str_pad($this->generatePin(5), 5, '0', STR_PAD_LEFT);

if ($digits == 6)
$token = str_pad($this->generatePin(6), 6, '0', STR_PAD_LEFT);
$token = $this->generatePin($digits);

Model::create([
'identifier' => $identifier,
Expand Down Expand Up @@ -103,7 +97,7 @@ private function generatePin($digits = 4)
$pin = "";

while ($i < $digits) {
$pin .= mt_rand(0, 9);
$pin .= random_int(0, 9);
$i++;
}

Expand Down

0 comments on commit ff8353d

Please sign in to comment.