Skip to content

Commit

Permalink
udated captcha driver initalization
Browse files Browse the repository at this point in the history
  • Loading branch information
RahulDey12 committed Sep 29, 2023
1 parent eabb75b commit fc70c81
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 51 deletions.
49 changes: 0 additions & 49 deletions src/CaptchaFactory.php

This file was deleted.

36 changes: 36 additions & 0 deletions src/CaptchaManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Rahul900day\Captcha;

use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\Manager;
use Illuminate\Support\Str;
use InvalidArgumentException;
use Rahul900day\Captcha\Contracts\Captcha;
use Rahul900day\Captcha\Drivers\HCaptcha;
use Rahul900day\Captcha\Drivers\ReCaptcha;
use Rahul900day\Captcha\Drivers\TurnstileCaptcha;
use Rahul900day\Captcha\Exceptions\InvalidCaptchaDriverException;

class CaptchaManager extends Manager
{
protected function createHCaptchaDriver(): Captcha
{
return new HCaptcha();
}

protected function createReCaptchaDriver(): Captcha
{
return new ReCaptcha();
}

protected function createTurnstileDriver(): Captcha
{
return new TurnstileCaptcha();
}

public function getDefaultDriver()
{
return config('captcha.driver');
}
}
2 changes: 1 addition & 1 deletion src/CaptchaServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function register()
);

$this->app->singleton(CaptchaContract::class, function ($app) {
return (new CaptchaFactory(config('captcha')))->make();
return new CaptchaManager($app);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/FakeCaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getJs(?string $hl): string
input.setAttribute('type', 'hidden');
input.setAttribute('name', '{$this->getResponseName()}')
input.setAttribute('value', 'pass')
container.appendChild(input)
container.parentElement.appendChild(input)
})
</script>
HTML;
Expand Down

0 comments on commit fc70c81

Please sign in to comment.