jadjoubran / laravel5-angular-material-starter

Get started with Laravel 5.3 and AngularJS (material)
https://laravel-angular.readme.io/
MIT License
1.67k stars 401 forks source link

JWT not working out of the box because AuthenticateController #81

Closed jfhernandeze closed 8 years ago

jfhernandeze commented 8 years ago

If I use it out of the box I keep getting this error:

Error: Expecting a token named "token" but instead got: {"data":{"token":"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsImlzcyI6Imh0dHA6XC9cL2xvY2FsaG9zdDo4MDAwXC9hcGlcL2F1dGhlbnRpY2F0ZVwvYXV0aCIsImlhdCI6IjE0NDQ4NzQ2NTMiLCJleHAiOiIxNDQ0ODc4MjUzIiwibmJmIjoiMTQ0NDg3NDY1MyIsImp0aSI6IjNkMTZiM2UwZDQ3ZTE4ZjUwZDMyMDY1YjM1ZjUwOWNkIn0.OIekyUWq6D-ftpK66h5Yvbg7VmnQHr9E9DMKdpMzTXc"}}

I just change this line in AuthenticateController.php

// if no errors are encountered we can return a JWT
        return response()->api(compact('token'));

to:

return compact('token');

And works perfectly

jadjoubran commented 8 years ago

That's true indeed. Thanks for noticing it out and reprinting it. Would you mind sending a pull request with a fix and a comment why we can't use response macros here?

masterpowers commented 8 years ago

@jfhernandeze hope you can tell use how to produce this error so we can make correction and test it as well

jadjoubran commented 8 years ago

@masterpowers you just need to return compact('token'); instead of response()->api(compact('token')); Give it a try and let me know if it works

jfhernandeze commented 8 years ago

Yes I will send a pull request to fix this

On Thu, Oct 15, 2015 at 5:39 AM, Jad Joubran notifications@github.com wrote:

@masterpowers https://github.com/masterpowers you just need to return compact('token'); instead of response()->api(compact('token')); Give it a try and let me know if it works

— Reply to this email directly or view it on GitHub https://github.com/jadjoubran/laravel5-angular-material-starter/issues/81#issuecomment-148347339 .

jadjoubran commented 8 years ago

Thanks @jfhernandeze @masterpowers this has been fixed through #82 - let me know if this works for you Ths fix will be available in 2.10.2