Skip to content

Commit

Permalink
Merge pull request #3 from ibrahem-kamal/development
Browse files Browse the repository at this point in the history
added otp handlers
  • Loading branch information
ibrahem-kamal committed Feb 5, 2024
2 parents b86089c + 3ac28df commit 5a1f61d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Contracts/OtpHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Ibrahemkamal\Otp\Contracts;

use Ibrahemkamal\Otp\Models\OtpCode;

interface OtpHandler
{
public function handle(OtpCode $otpCode);
}
6 changes: 6 additions & 0 deletions src/Otp.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ public function verifyOtp(string $otp): ServiceResponse
}
/** @phpstan-ignore-next-line */
$otpCode->verified_at = now();
/** @phpstan-ignore-next-line */
if ($handlers = config('otp.services.'.$otpCode->service.'.handlers')) {
foreach ($handlers as $handler) {
app($handler)::handle($otpCode);
}
}

return $this->serviceResponse->setSuccess(true)->setData($otpCode);
}
Expand Down

0 comments on commit 5a1f61d

Please sign in to comment.