Support the ongoing development of Laravel.io →
posted 10 years ago
Views Blade

Is this a filter order issue? In the first filter I set up a object needed for authentication (later),

global $edgeApp;

Route::filter('connect', function() {
            global $edgeApp;
            $edgeApp = new BillMax\EdgeApp;
            
            $edgeApp->login();   
        });
Route::when('secure/*', 'connect');

In the second filter (on the same path), the redirect is a login page.

Route::filter('auth', function() {
            if (Auth::guest()) {
                if (Request::ajax()) {
                    return Response::make('Unauthorized', 401);
                } else {
                    return Redirect::guest('login');
                }
            }
        });
Route::when('secure/*', 'auth');

Which is display via:

return View::make('login', array('edgeApp' => $GLOBALS['edgeApp']) );

The trouble is the $edgeApp variable is NULL when the login template is rendered. What am I doing wrong?

B

Last updated 3 years ago.
0

Please ignore, The issue was the redirect generates a new request where the EdgeApp obj was not initialized.

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

bschooly bschooly Joined 1 Oct 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.