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

WBOY
Release: 2016-06-06 20:06:39
Original
1144 people have browsed it

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

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

回复内容:

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

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

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

<code> Route::group(['middleware' => ['auth:account']], function () {
        Route::controller('account/wechat', 'Account\WechatController');
        Route::controller('wechat/website', 'Wechat\WebsiteController');
  });
     </code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template