tappleby / laravel-auth-token

Hooks into the laravel auth module and provides an auth token upon success. This token is really only secure in https environment. This main purpose for this module was to provide an auth token to javascript web app which could be used to identify users on api calls.
MIT License
255 stars 64 forks source link

Auth::user is empty after before => auth.token #28

Closed Hesesses closed 10 years ago

Hesesses commented 10 years ago

Hello,

Logins etc works perfectly but when I am using before filter with auth.token, laravel's Auth::user is empty, any ideas whats wrong?

Route::group(array('prefix' => 'v1','before' => 'auth.token'), function() { Route::post('events','EventtiController@store'); });

tappleby commented 10 years ago

Are you setting the user when auth.token.valid event is fired?

Event::listen('auth.token.valid', function($user)
{
  //Token is valid, set the user on auth system.
  Auth::setUser($user);
});

The various events are mentioned here: https://github.com/tappleby/laravel-auth-token/blob/master/README.md#events

Hesesses commented 10 years ago

Oh my bad! I thought those event listeners were already included in the code.