Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: event injection #2

Closed
bingalls opened this issue Sep 21, 2014 · 1 comment
Closed

enhancement: event injection #2

bingalls opened this issue Sep 21, 2014 · 1 comment

Comments

@bingalls
Copy link

Please add an event to inject auth into controllers in routes.php, as described in
http://laravel.io/forum/05-04-2014-add-additional-filter-class-to-composer-package
The simplified example below could be moved into an event

If you implement this as documentation instead, please add info on expiring & refreshing tokens.

  Route::group(array('prefix' => '/api/v1')), function() {   //add 'before' => 'myEvent'
    $payload = Input::get('auth_token');
    if ($payload) {
        try {
            $user = JWTAuth::toUser($payload);
            if ($user) {
                Auth::setUser($user);
                //Add your sensitive pages here
                Route::controller('companies', 'ProtectedController');
            }
        } catch (Exception $ex) {
            Log::notice("Auth token failure $payload", [__FILE__, __LINE__]);
            //Dumping $ex will cause an out of memory exception
        }
    }
  });
@tymondesigns
Copy link
Owner

Yea, I will add a jwt-auth filter for sure. I hope to complete most of the documentation write up this coming week.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants