Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
<?php
namespace HiEvents\Http\Actions\Users;
use HiEvents\Http\Actions\BaseAction;
use HiEvents\Http\Attributes\AllowedForReadOnlyUsers;
use HiEvents\Services\Application\Handlers\User\ResendEmailConfirmationHandler;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Cache;
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
#[AllowedForReadOnlyUsers]
class ResendEmailConfirmationAction extends BaseAction
{
public function __construct(
private readonly ResendEmailConfirmationHandler $resendEmailConfirmationHandler,
) {}
public function __invoke(int $userId): Response
{
$user = $this->getAuthenticatedUser();
$cacheKey = 'resend_email_confirmation:'.$user->getId();
if (Cache::has($cacheKey)) {
$remainingSeconds = Cache::get($cacheKey) - now()->timestamp;
throw new TooManyRequestsHttpException($remainingSeconds, __(
'Please wait :seconds seconds before requesting another code.', [
'seconds' => $remainingSeconds,
]));
}
Cache::put($cacheKey, now()->addSeconds(30)->timestamp, 30);
$this->resendEmailConfirmationHandler->handle($user, $this->getAuthenticatedAccountId());
return $this->noContentResponse();
}
}