laravel 5的CKFinder身份验证问题 [英] CKFinder Authentication issue with laravel 5

查看:116
本文介绍了laravel 5的CKFinder身份验证问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Laravel5.我在/public/plugins/ckfinder目录中有引用ckfinder的文件夹.

I'm using Laravel 5. I have folder that references ckfinder in /public/plugins/ckfinder directory.

我需要使用config.php中的CheckAuthentication函数,但是会话值和Auth Class为空.

CheckAuthentication function in config.php is I need to use but session value and Auth Class is null.

我尝试过

function CheckAuthentication(){
    return Auth::check();
}

 //Ckfinder Config.php
function CheckAuthentication(){
        if($_SESSION['ckfinder_enabled'] == 'enabled') {
            return true;
        } else {
            return false;
        }
    }

 

        //App\Http\Middleware\Authenticate.php
    public function handle($request, Closure $next)
            {
                if ($this->auth->guest()){
                        if ($request->ajax()){
                            return response('Unauthorized.', 401);
                        }else{
                            return redirect()->guest('auth/login');
                        }
                    }

                if($this->auth->check()) {
                     $_SESSION['ckfinder_enabled'] = 'enabled';
                    return $next($request);
                }
            }

推荐答案

我也遇到了同样的问题.您的代码对于laravel 4.2很有用,但是对于laravel 5,您需要在ckfinder文件夹的config.php中执行此操作:

I had the same issue too. Your code is useful for laravel 4.2 but for laravel 5 you need to do this in ckfinder folder's config.php:

require _DIR_.'/../../../bootstrap/autoload.php';
$app = require_once _DIR_.'/../../../bootstrap/app.php';

$app->make('Illuminate\Contracts\Http\Kernel')
  ->handle(Illuminate\Http\Request::capture());

然后您就可以使用以下代码:

Then you are ready to go with this code:

function CheckAuthentication(){
    return Auth::check();
}

这应该有效.

这篇关于laravel 5的CKFinder身份验证问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆