jeudi 24 décembre 2015

Jwt Tymon laravel 5.1 + angularjs multiple async call error user_not_found

I'm using a Laravel Api and AngularJs frontend. I have a problem with a middleware JWT.auth (tymondesign library) because if I do multiple asynchronous request from my frontend angularjs to backend api Laravel, sometimes (yes not always return error), return a 404 error "user_not_found" by middleware.

But doesn't return error in all request but in some. I have no idea why this happens.

More clearly:

I have 4 ajax call from Angularjs Service that return a promise and in back end I have a route group under middleware JWT.auth

In my angularjs controller 4 call from 4 different services:

User.findAll().then(function(data){ $scope.users = data },function(err){});
Alert.findAll().then(function(data){ $scope.alerts = data},function(err){});
Workgroups.findAll().then(function(data){ $scope.workgroups = data},function(err){});
Usergroups.findAll().then(function(data){ $scope.usergroups = data},function(err){});

And backend example (I'm sorry for syntax):

Route::group(['middleware'=>['jwt.auth']){
        Route::get('findAllUsers','userController@findAll');
        Route::get('findAlerts','alertController@findAll');
        Route::get('findAllWorkgroups','workgroupsController@findAll');
        Route::get('findAllUsergroups','usergroupsController@findAll');
    }

And someTimes one of this calls return exception from middleware Jwt : 404, "user_not_found".

For more information, I'm using Laravel 5.1 and Tymon JWT 0.5.6-master and The token is passed by header Authorization.

Is it a bug or am I doing something wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire