Laravel 5.7 @csrf is not working after enabling HTTPS

时间:2019-03-05 16:40:08

标签: php laravel

Initially my laravel application was working on HTTP protocol, Then I changed the protocol to HTTPS.
Unfortunately now my application's login is not working now.it shows me 419 error, Sorry Your session expired. I tried couple of solutions suggested.
https://laracasts.com/discuss/channels/laravel/post-request-in-laravel-57-error-419-sorry-your-session-has-expired.

Laravel 419 Error - VerifyCsrfToken issue

Post request in Laravel 5.7 --- Error - 419 Sorry, your session has expired.

But none of these solved my issue.

I am using CRUDBOOSTER plugin to manage login.

Routes.php.

/* ROUTER FOR WEB */
Route::group(['middleware' => ['web'], 'prefix' => config('crudbooster.ADMIN_PATH'), 'namespace' => $namespace], function () {

    Route::post('unlock-screen', ['uses' => 'AdminController@postUnlockScreen', 'as' => 'postUnlockScreen']);
    Route::get('lock-screen', ['uses' => 'AdminController@getLockscreen', 'as' => 'getLockScreen']);
    Route::post('forgot', ['uses' => 'AdminController@postForgot', 'as' => 'postForgot']);
    Route::get('forgot', ['uses' => 'AdminController@getForgot', 'as' => 'getForgot']);
    Route::post('register', ['uses' => 'AdminController@postRegister', 'as' => 'postRegister']);
    Route::get('register', ['uses' => 'AdminController@getRegister', 'as' => 'getRegister']);
    Route::get('logout', ['uses' => 'AdminController@getLogout', 'as' => 'getLogout']);
    Route::post('login', ['uses' => 'AdminController@postLogin', 'as' => 'postLogin']);
    Route::get('login', ['uses' => 'AdminController@getLogin', 'as' => 'getLogin']);
});  

My Form

 <form autocomplete='off' action="{{ route('postLogin') }}" method="post">
    @csrf
        <!-- <input type="hidden" name="_token" value="{{ csrf_token() }}"/> -->
        <div class="form-group has-feedback">
            <input autocomplete='off' type="text" class="form-control" name='email' required placeholder="Email"/>
            <span class="glyphicon glyphicon-user form-control-feedback"></span>
        </div>
        <div class="form-group has-feedback">
            <input autocomplete='off' type="password" class="form-control" name='password' required placeholder="Password"/>
            <span class="glyphicon glyphicon-lock form-control-feedback"></span>
        </div>
        <div style="margin-bottom:10px" class='row'>
            <div class='col-xs-12'>
                <button type="submit" class="btn btn-primary btn-block btn-flat"><i class='fa fa-lock'></i> {{trans("crudbooster.button_sign_in")}}</button>
            </div>
        </div>

        <div class='row'>
            <div class='col-xs-12' align="center"><p style="padding:10px 0px 10px 0px">{{trans("crudbooster.text_forgot_password")}} <a
                            href='{{route("getForgot")}}'>{{trans("crudbooster.click_here")}}</a></p></div>
        </div>
    </form>. 

And I attaching my error screen. Error Screen

can any one help me rid this issue.

1 个答案:

答案 0 :(得分:0)

如果您可以看到隐藏的CSRF HTML输入字段,请清除缓存的数据:

{
title : [question, question],
title2: [question],
title3: [question, question, question]
}

并重新生成一个新密钥:

php artisan cache:clear
php artisan view:clear