【问题标题】:Mews Captcha validation doesn't work when the form is embedded in an iframe当表单嵌入 iframe 时,Mews Captcha 验证不起作用
【发布时间】:2022-10-08 14:55:10
【问题描述】:

我正在尝试将验证码添加到表单中,一切正常。 当我将该表单添加到 iFrame 时,我开始从验证码中收到验证错误。 我正在使用 Laravel 7.3 喵喵叫/验证码 3.2

我得到的错误:

Illuminate\Validation\ValidationException: The given data was invalid. in /var/www/html/vendor/laravel/framework/src/Illuminate/Validation/Validator.php:452

html代码:

<span id="captchaspan"> {!! captcha_img('flat') !!}</span>
    <button type="button" class="btn btn-success" id="refresh"><i class="fa fa-refresh" ></i></button>

javascript代码:

<script type="text/javascript">
        $('.btn-success').click(function(){
            $.ajax({
                type:'GET',
                url:'/refresh-captcha',
                datatype:'json',
                success: function(data){
                    $(".captcha span").html(data.captcha);
                }
            });
        });
    </script>

在控制器中:

try {
            request()->validate(['captcha' => 'required|captcha']);
    }catch (\Exception $e){
            file_put_contents('log.log', ' captcha problem '.$e,8);
            return back()->with('error', 'Captcha Error');
    }   

刷新验证码方法

public function refreshCaptcha()
    {
        return response()->json(['captcha'=> captcha_img('flat')]);
    }

重要的: 仅当表单嵌入 iframe 时才会出现此问题。

非常感谢提前。 格拉津

【问题讨论】:

    标签: laravel iframe captcha


    【解决方案1】:

    我不确定这是否有帮助,但我对这个库有问题,经过数小时试图找出问题并分析它,库本身的问题,没有经过很好的测试,无论如何我的问题出在配置中/mews php captcha 文件中有一个名为 math 的属性,我只是禁用了它,现在检查工作正常,我希望这对将来的任何人都有帮助 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-23
      • 2018-08-21
      • 1970-01-01
      • 2014-02-19
      • 2021-12-01
      • 1970-01-01
      • 2017-10-07
      相关资源
      最近更新 更多