mewebstudio / captcha

Captcha for Laravel 5/6/7/8/9/10/11
MIT License
2.45k stars 453 forks source link

用在Dcat-admin里时会出现两个session #206

Open NightDragonOne opened 3 years ago

NightDragonOne commented 3 years ago

php:7.4.7 laravel:7.28.4 dcat-admin:1.7.4

When refreshing this page, two sessions will be generated, and captcha is not saved in the current session

<fieldset class="form-label-group form-group position-relative has-icon-left">
                        <input id="captcha" type="text" class="form-control float-left col-6" name="captcha" >
                        <span><img class="float-left col-6" src="{{ captcha_src('default') }}" onclick="this.src='/captcha?'+Math.random()"></span>
                        <div class="form-control-position">
                            <i class="feather icon-shield"></i>
                        </div>
                        <label for="captcha" >验证码</label>

                        <div class="help-block with-errors"></div>
                        @if($errors->has('captcha'))
                            <span class="invalid-feedback text-danger" role="alert">
                                            @foreach($errors->get('captcha') as $message)
                                    <span class="control-label" for="inputError"><i class="feather icon-x-circle"></i> {{$message}}</span><br>
                                @endforeach
                                        </span>
                        @endif
                   </fieldset>
Z-hu commented 3 years ago

我也碰到了相同的问题,老哥你是怎么解决的呢??

NightDragonOne commented 3 years ago

我也碰到了相同的问题,老哥你是怎么解决的呢??

弃用,没有办法,没有能力兼容

ericyzhu commented 3 years ago

在 AppServiceProvider 的 boot 方法里加上下面这段,从 Dact 里扒出来的。

if (config('admin.route.enable_session_middleware') || config('admin.multi_app')) {
    $path = '/'.trim(config('admin.route.prefix'), '/');
    config(['session.path' => $path]);
}