bug*_*ney 2 php ckfinder laravel-5
我正在使用Laravel5。我在/ public / plugins / ckfinder目录中有引用ckfinder的文件夹。
我需要使用config.php中的CheckAuthentication函数,但是会话值和Auth Class为null。
我试过了
function CheckAuthentication(){
return Auth::check();
}
Run Code Online (Sandbox Code Playgroud)
要么
//Ckfinder Config.php
function CheckAuthentication(){
if($_SESSION['ckfinder_enabled'] == 'enabled') {
return true;
} else {
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
//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);
}
}
Run Code Online (Sandbox Code Playgroud)
小智 5
我也有同样的问题。您的代码对于laravel 4.2有用,但是对于laravel 5,您需要在ckfinder文件夹的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());
Run Code Online (Sandbox Code Playgroud)
然后就可以使用以下代码了:
function CheckAuthentication(){
return Auth::check();
}
Run Code Online (Sandbox Code Playgroud)
这应该工作。
| 归档时间: |
|
| 查看次数: |
2103 次 |
| 最近记录: |