Session 如何从公共目录获取Larvel5.3会话数据或身份验证数据?
我在公共目录中编写了一些php函数,因为我必须使用外部库。 然后,我无法从我使用下面的php脚本测试的控制器中检索任何会话数据和身份验证数据Session 如何从公共目录获取Larvel5.3会话数据或身份验证数据?,session,laravel-5,laravel-5.3,Session,Laravel 5,Laravel 5.3,我在公共目录中编写了一些php函数,因为我必须使用外部库。 然后,我无法从我使用下面的php脚本测试的控制器中检索任何会话数据和身份验证数据 session_start(); var_dump($_SESSION['user']); 我已经从AdminMiddlware获得了初始会话数据 在资源->查看目录中使用它非常棒,但不能公开使用 namespace App\Http\Middleware; use App\User; use Closure; use Illuminate\Suppo
session_start();
var_dump($_SESSION['user']);
我已经从AdminMiddlware获得了初始会话数据
在资源->查看目录中使用它非常棒,但不能公开使用
namespace App\Http\Middleware;
use App\User;
use Closure;
use Illuminate\Support\Facades\Auth;
class AdminMiddleware
{
/**
* Handle an incoming request. User must be logged in to do admin check
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$user = User::find(\Auth::user()->id);
if ((int) $user->is_admin == (int) config('auth.guards.is_admin')) {
$collection = collect(Auth::user());
$thisdata = $collection->toArray();
$request->session()->put('user', $thisdata);
return $next($request);
}
return redirect()->guest('/');
}}
好的,我能看到的最简单的方法是,让它与Laravel一起工作: (如果您尚未这样做)复制 到 然后将
“文件连接器”
(第25行)设置为“/authenticate filemanager”
,例如
"fileConnector": "/authenticate-filemanager",
这将告诉您的Filemanager
应用程序通过路径/authenticate Filemanager
加载
接下来,转到public/gallery/connectors/php/application/FmApplication.php
,并在底部将if(!auth())
更改为if(!auth()->check())
这将告诉应用程序在Laravel中使用内置的auth
然后您需要设置实际的路由(这基本上是filemanager.php
的内容,没有auth()
函数):
因为GET
和POST
调用都是对同一个端点进行的,所以使用了match
。确保不要将此路由放在auth中间件后面
最后,您只需转到app/Http/Middleware/VerifyCsrfToken.php
并将'authenticate-filemanager'
添加到$except
数组中,即可禁用路由的csrf
希望这有帮助 好的,我能看到的最简单的方法是: (如果您尚未这样做)复制 到 然后将
“文件连接器”
(第25行)设置为“/authenticate filemanager”
,例如
"fileConnector": "/authenticate-filemanager",
这将告诉您的Filemanager
应用程序通过路径/authenticate Filemanager
加载
接下来,转到public/gallery/connectors/php/application/FmApplication.php
,并在底部将if(!auth())
更改为if(!auth()->check())
这将告诉应用程序在Laravel中使用内置的auth
然后您需要设置实际的路由(这基本上是filemanager.php
的内容,没有auth()
函数):
因为GET
和POST
调用都是对同一个端点进行的,所以使用了match
。确保不要将此路由放在auth中间件后面
最后,您只需转到app/Http/Middleware/VerifyCsrfToken.php
并将'authenticate-filemanager'
添加到$except
数组中,即可禁用路由的csrf
希望这有帮助 RichFileManager版本的更新。2.7.6和拉威尔5.6 我在管理面板的HTML文本编辑器中使用RichFilemanager。所以检查管理员用户是否已登录
“connectorUrl”:“/admin/authenticate filemanager”,
Route::match(['GET', 'POST'], '/admin/authenticate-filemanager', function () {
//Here check is admin or user is authenticated. Can use: auth()->check()
$isAuth = \App\Libraries\Admin\AdminBLL::isAuth();
if(!$isAuth){
return 'Not authenticated';
}
return require_once(public_path('assets/plugins/RichFilemanager/connectors/php/filemanager.php'));
}))app/Http/Middleware/VerifyCsrfToken.php
并将'admin/authenticate filemanager'
添加到$except数组中,即可禁用路由的csrfpublic/./RichFilemanager/connectors/php/filemanager.php
$local->setRoot('userfiles/filemanager',true,true)代码>
RichFilemanger版本的更新。2.7.6和拉威尔5.6 我在管理面板的HTML文本编辑器中使用RichFilemanager。所以检查管理员用户是否已登录
“connectorUrl”:“/admin/authenticate filemanager”,
Route::match(['GET', 'POST'], '/admin/authenticate-filemanager', function () {
//Here check is admin or user is authenticated. Can use: auth()->check()
$isAuth = \App\Libraries\Admin\AdminBLL::isAuth();
if(!$isAuth){
return 'Not authenticated';
}
return require_once(public_path('assets/plugins/RichFilemanager/connectors/php/filemanager.php'));
}))app/Http/Middleware/VerifyCsrfToken.php
并将'admin/authenticate filemanager'
添加到$except数组中,即可禁用路由的csrfpublic/./RichFilemanager/connectors/php/filemanager.php
$local->setRoot('userfiles/filemanager',true,true)代码>
Laravel不使用本机会话。为什么你不能在你的应用程序中使用这个
外部库
?我已经包括了用于上传和控制所有媒体的富文件管理器,但是我应该将这些文件夹保存在公共目录中,而不是资源目录中,这就是为什么我需要扩展LR53。会话,用于检查登录用户可以访问的任何内容。没有任何解决方案解决此问题,对吗?能否显示要从中访问会话的文件(整个文件)的内容?我已将此项目公开给github您可以在下面链接我使用//测试会话用户数据。会话_start();变量转储($_会话['user'])//结束测试会话Ravel不使用本机会话。为什么你不能在你的应用程序中使用这个外部库
?我已经包括了用于上传和控制所有媒体的富文件管理器,但是我应该将这些文件夹保存在公共目录中,而不是资源目录中,这就是为什么我需要扩展LR53。会话,用于检查登录用户可以访问的任何内容。没有任何解决方案解决此问题,对吗?能否显示要从中访问会话的文件(整个文件)的内容?我已将此项目公开给github您可以在下面链接我使用//测试会话用户数据。会话_start();变量转储($_会话['user'])//结束测试会话CKEDITOR.replace('textarea',{filebrowserBrowseUrl:'{!!url('gallery')!!}',ImageBrowser:true,autoUpdateElement:true,
Route::match(['GET', 'POST'], '/admin/authenticate-filemanager', function () {
//Here check is admin or user is authenticated. Can use: auth()->check()
$isAuth = \App\Libraries\Admin\AdminBLL::isAuth();
if(!$isAuth){
return 'Not authenticated';
}
return require_once(public_path('assets/plugins/RichFilemanager/connectors/php/filemanager.php'));