Skip to content

Commit

Permalink
添加验证码位置设置。
Browse files Browse the repository at this point in the history
  • Loading branch information
deatil committed Mar 20, 2023
1 parent 1c6bdda commit 688c3e2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
12 changes: 9 additions & 3 deletions resources/lang/en/captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@
'captcha_error' => 'Captcha error',

'setting' => 'Captcha setting',

'charset' => 'Captcha Charset',
'charset_help' => 'Captcha Charset need String',

'codelen' => 'Captcha Codelen',
'codelen_help' => 'Captcha Codelen need String',

'fontsize' => 'Captcha Fontsize',

'captcha_type' => 'Captcha Type',
'captcha_type_string' => 'String',
'captcha_type_math' => 'Math',
'charset_help' => 'Captcha Charset need String',
'codelen_help' => 'Captcha Codelen need String',

'captcha_position' => 'Captcha Position',
'captcha_position_help' => 'Captcha position empty is default setting. Default is [#login-form fieldset.form-label-group:eq(1)]',
];
10 changes: 8 additions & 2 deletions resources/lang/zh_CN/captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@
'captcha_error' => '验证码错误',

'setting' => '登陆验证码设置',

'charset' => '随机因子',
'charset_help' => '随机因子需验证码类型为字符有效',

'codelen' => '验证码长度',
'codelen_help' => '验证码长度需验证码类型为字符有效',

'fontsize' => '字体大小',

'captcha_type' => '验证码类型',
'captcha_type_string' => '字符',
'captcha_type_math' => '数学公式',

'charset_help' => '随机因子需验证码类型为字符有效',
'codelen_help' => '验证码长度需验证码类型为字符有效',
'captcha_position' => '验证码位置',
'captcha_position_help' => '验证码位置不设置为默认。默认位置为[#login-form fieldset.form-label-group:eq(1)]',
];
3 changes: 2 additions & 1 deletion src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class_alias(__CLASS__, 'LakeLoginCaptcha');
if (Helper::matchRequestPath('get:'.$except)) {
$defaultCaptcha = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIIAAAAyCAYAAACQy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6nCYG91IrsvMIFHJnxysSx90PJ4rxoErN43oBqb7bvSxp1x+OIECJ9z20b4CXiV8DpBc6YbekaTAC7GhotpRnKJ0zW5/huGnvK+/V4nJAjACS/1OOdPJJV1RKFGgmDUjuDpLqCijgV6lm+OLzGFpntB4R1fWf4yW5iySMaf3xrII5kIKpfZUlUAWUZ9/6Rxw4idCqqK/UDkOZi+z2AXj0bKszox0xqpgthUdq29p0dQUbDNXlUzRsri+TFz5ALvaoYvz7eHwxXLIcri+MsDt1diF6Gewe1WDXBvlIRJPoNVDB1nhjVR6OEiMqvoQ8jWUxgX+SANwkTFrJq1u8kibFJFuMYcAlGxTIiAtkw2QPfrJ3vJm6mvF+Nx0lbw72xJERm+2OCECpUSswRZIcCjloNFUDeKRRaOZpJz06UpgUWMpjy9o4qZ6Ohk73wha0GG9+ZvrCarcQjss3YGlhoV2r0/f4/YCUiVh+WsTWsjiEY8ICBIAQPguADhCAEH6LgAYYgBA+C4AOEIAQfouABhiAED4LgAwTPj48+ULQNDGFF2EacjV4GIRgp2kaDIIRtxNnoZRCCkaJtNAhC2EacjV7+B1T7RDhNUhVIAAAAAElFTkSuQmCC';
$captchaUrl = admin_route('lake-login-captcha.show');
$captchaPosition = static::setting('captcha_position') ?: '#login-form fieldset.form-label-group:eq(1)';
$script = '
;(function() {
var captcha_tpl = \'<fieldset class="form-label-group form-group position-relative has-icon-left lake-login-captcha">\'
Expand All @@ -65,7 +66,7 @@ class_alias(__CLASS__, 'LakeLoginCaptcha');
captcha_tpl += \'<label for="captcha">'.static::trans('captcha.captcha').'</label>\'
captcha_tpl += \'<div class="help-block with-errors"></div>\'
captcha_tpl += \'</fieldset>\';
$(captcha_tpl).insertAfter($("#login-form fieldset.form-label-group").get(1));
$(captcha_tpl).insertAfter($("'.$captchaPosition.'").get(0));
$("#verify").click(function() {
var verifyimg = $(this).data("src");
$(this).attr("src", verifyimg.replace(/\?.*$/, "") + "?" + Math.random());
Expand Down
10 changes: 7 additions & 3 deletions src/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ public function title()
*/
protected function formatInput(array $input)
{
$input['charset'] = $input['charset'] ?: 'abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ23456789';
$input['codelen'] = $input['codelen'] ?: 4;
$input['fontsize'] = $input['fontsize'] ?: 20;
$input['captcha_type'] = $input['captcha_type'] ?: 'string';
$input['fontsize'] = $input['fontsize'] ?: 20;
$input['codelen'] = $input['codelen'] ?: 4;
$input['charset'] = $input['charset'] ?: 'abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ23456789';
$input['captcha_position'] = $input['captcha_position'] ?? '';

return $input;
}
Expand All @@ -53,5 +54,8 @@ public function form()
$this->textarea('charset', $this->trans('captcha.charset'))
->default('abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ23456789')
->help($this->trans('captcha.charset_help'));
$this->text('captcha_position', $this->trans('captcha.captcha_position'))
->default('')
->help($this->trans('captcha.captcha_position_help'));
}
}
6 changes: 3 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?php

return [
'1.0.6' => [
'优化验证码页面显示。优化dcat新版验证码不显示问题。',
],
'1.0.7' => [
'添加数学公式验证码。',
],
Expand All @@ -16,4 +13,7 @@
'1.0.10' => [
'修复执行视图缓存脚本报错问题。',
],
'1.0.11' => [
'添加验证码位置设置。',
],
];

0 comments on commit 688c3e2

Please sign in to comment.