mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-07-07 16:32:48 +08:00
feat(admin): 为登录功能添加验证码开关配置
- 在环境变量中引入 `captcha_login` 配置项,用于控制登录时是否需要验证码 - 根据配置动态显示或隐藏登录页面的验证码输入框 - 后端登录验证逻辑根据配置决定是否校验验证码
This commit is contained in:
@@ -18,7 +18,7 @@ class Login extends Common
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
View::assign('captcha_login', env('captcha_login', true));
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
@@ -27,13 +27,14 @@ class Login extends Common
|
||||
{
|
||||
$post_data = $this->request->post();
|
||||
|
||||
|
||||
|
||||
$validate = Validate::rule('account',Rule::isRequire())
|
||||
->rule('password',Rule::isRequire())
|
||||
->rule('captcha',function($value){
|
||||
return \captcha_check($value)?true:'验证码错误';
|
||||
});
|
||||
->rule('password',Rule::isRequire());
|
||||
|
||||
if (env('captcha_login', true)) {
|
||||
$validate->rule('captcha',function($value){
|
||||
return \captcha_check($value)?true:'验证码错误';
|
||||
});
|
||||
}
|
||||
|
||||
if(!$validate->check($post_data)){
|
||||
return json_message($validate->getError());
|
||||
|
||||
Reference in New Issue
Block a user