欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

laravel5.2 如何在用户认证中间件外的控制器里获取用户详情

程序员文章站 2022-05-27 11:43:29
...
    Route::group(['middleware' => ['auth:account']], function () {
        Route::controller('account/wechat', 'Account\WechatController');
    });
    
    Route::controller('wechat/website', 'Wechat\WebsiteController');

已经登录进account/wechat了,在WechatController里能用Auth::user()获取到用户详情
但是在WebsiteController却获取不到,怎么解决 ?

回复内容:

    Route::group(['middleware' => ['auth:account']], function () {
        Route::controller('account/wechat', 'Account\WechatController');
    });
    
    Route::controller('wechat/website', 'Wechat\WebsiteController');

已经登录进account/wechat了,在WechatController里能用Auth::user()获取到用户详情
但是在WebsiteController却获取不到,怎么解决 ?

不知道你的middleware是具体怎么实现的,大概可以尝试:

 Route::group(['middleware' => ['auth:account']], function () {
        Route::controller('account/wechat', 'Account\WechatController');
        Route::controller('wechat/website', 'Wechat\WebsiteController');
  });
     
相关标签: php laravel