Reputation: 564
I'm trying to implement the new Laravel 5.3
auth:api middleware
using api tokens. Since I already have a legacy users table containing an 'ApiToken' field I would like to change the TokenGuard storageKey property (and possibly also the inputKey) to "ApiToken" instead of 'api_token'
. Similar to the getRememberTokenName
method, I couldn't find a 'getApiTokenName
' method however. Is there a way to accomplish this without altering the Laravel TokenGuard source?
Upvotes: 3
Views: 717
Reputation: 796
You cannot override the storageKey in TokenGuard class. But you have 2 options to solve your problem:
Create your custom guard which should be extended from TokenGuard and inside it change the 'storageKey' property. And then register your custom guard inside AuthServiceProvider as your guard and use them.
Change 'ApiToken' field in your table to snake_case.
Upvotes: 3