laravel-auth-token icon indicating copy to clipboard operation
laravel-auth-token copied to clipboard

Send token via header response

Open harpster604 opened this issue 10 years ago • 0 comments

During user authentication using the AuthTokenController@store I need to send the user as a json response but the token in the header.

So I need something like this instead of the current response:

return Response::json(array('token' => $serializedToken, 'user' => $user->toArray()))->header('X-Auth-Token', $serializedToken);

What is the best way to extend and include this functionality. I extended the controller (CustomAuthTokenController) in app/controllers and overrode the store() function, then updated the routes.php to use the extended controller, but I'm new to Laravel so I don't think I'm doing this right. I get this response:

error: {type: "Illuminate\Container\BindingResolutionException",…}
file: "/home/vagrant/Code/wedding/vendor/laravel/framework/src/Illuminate/Container/Container.php"
line: 513
message: "Target [Tappleby\AuthToken\AuthTokenProviderInterface] is not instantiable."
type: "Illuminate\Container\BindingResolutionException"

harpster604 avatar Feb 03 '15 10:02 harpster604