Skip to content

Commit

Permalink
feat(config): Support for multi apps control enabled login captcha
Browse files Browse the repository at this point in the history
- Added 'enabled' key to the 'login-captcha.php' configuration file.
- Closes #35
  • Loading branch information
guanguans committed Oct 19, 2023
1 parent f3bcb47 commit 6e895c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/login-captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*/

return [
'enabled' => true,

'length' => 4,
'charset' => 'abcdefghijklmnpqrstuvwxyz23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',

Expand Down
5 changes: 5 additions & 0 deletions src/LoginCaptchaServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ protected function extendValidator(): self
protected function bootingCaptcha(): self
{
Admin::booting(function (): void {
$this->config = array_replace_recursive($this->config, config('admin.login_captcha', []));
if (! self::setting('enabled')) {
return;
}

$loginPath = ltrim(admin_base_path('auth/login'), '/');
if (Helper::matchRequestPath("GET:$loginPath")) {
Admin::script((string) view(sprintf('%s::captcha', $this->getName())));
Expand Down

0 comments on commit 6e895c9

Please sign in to comment.