Я пытаюсь интегрировать CKFinder с Laravel, и у меня получается около 95%. Я могу заставить все работать, кроме функции CheckAuthentication
— я должен сделать ее return true
независимо от того, чтобы загрузка работала.
Что я пытался сделать, так это загрузить Laravel в файле config.php, а затем проверить, вошел ли пользователь в систему, как показано ниже:
public/packages/ckfinder/config.php
<?php
/*
* ### CKFinder : Configuration File - Basic Instructions
*
* In a generic usage case, the following tasks must be done to configure
* CKFinder:
* 1. Check the $baseUrl and $baseDir variables;
* 2. If available, paste your license key in the "LicenseKey" setting;
* 3. Create the CheckAuthentication() function that enables CKFinder for authenticated users;
*
* Other settings may be left with their default values, or used to control
* advanced features of CKFinder.
*/
/** RIPPED FROM public/index.php **/
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/../../../bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let's turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight these users.
|
*/
$app = require __DIR__.'/../../../bootstrap/start.php';
/** END public/index.php **/
/**
* This function must check the user session to be sure that he/she is
* authorized to upload and access files in the File Browser.
*
* @return boolean
*/
function CheckAuthentication()
{
// WARNING : DO NOT simply return "true". By doing so, you are allowing
// "anyone" to upload and list the files in your server. You must implement
// some kind of session validation here. Even something very simple as...
return Auth::check();
}
Однако это всегда возвращает false. Я также пытался напрямую использовать Session
Laravel, чтобы установить переменную в значение true, когда кто-то входит в систему, и false, когда они выходят из системы, а затем проверяя это в файле config.php, но он всегда возвращает значение по умолчанию в Session::get("IsAuthorized", false);
. Может ли кто-нибудь предложить некоторые рекомендации относительно -
1) Как аутентифицировать, разрешено ли пользователю загружать?
2) Почему загрузка Laravel в другом файле заставляет его использовать отдельный сеанс, даже если он загружает одни и те же файлы?