Test logged in user has correct id in Laravel 4

筅森魡賤 提交于 2019-12-05 08:03:57

Got some help through the Laravel irc channel.

This is the way I have gone with.

Route::filter('user', function($route, $request)
{
    if( $request->segment(2) != Auth::user()->id)
    {
        return Redirect::to('/login');
    }
});

Then on my route do.

Route::get('user/{id}', array('before' => 'auth|user', 'uses' => 'UsersController@index'));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!