我目前正试图从CodeIgniter转到Laravel。
我已经成功地实现了杂交方法,但它似乎只适用于它指定的路由。
我尝试过搜索教程和示例,但即使它们也只显示出auth正在使用1条路径。
我如何给每个路由赋予一些功能来检查用户是否已登录?
需要为之服务的团体。
Route::group(array('before' => 'auth'), function()
{
// ALL ROUTES WITH AUTH NEEDED
});这似乎叫正常的auth,我用的是杂交瘤
Route::get('social/{action?}', array("as" => "hybridauth", function($action = "")
{
if ($action == "auth") {
try {
Hybrid_Endpoint::process();
}
catch (Exception $e) {
return Redirect::route('hybridauth');
}
return;
}
try {
$socialAuth = new Hybrid_Auth(app_path() . '/config/hybridauth.php');
$provider = $socialAuth->authenticate("facebook");
$userProfile = $provider->getUserProfile();
}
catch(Exception $e) {
return $e->getMessage();
}
echo "<pre>" . print_r( $userProfile, true ) . "</pre><br />";
}));发布于 2013-08-12 21:40:53
如果要在每条路径上运行请求,请使用筛选器。
App::before(function($request)
{
//check if user logged in here
});或创建筛选器并分组路由。
Route::group(array('before' => 'auth'), function()
{
});https://stackoverflow.com/questions/18197000
复制相似问题