-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding additional data to createToken #55
Comments
|
You're mentioning a tenant ID. Isn't it just the case of adding the |
I was just using the tenant id as a vague example. You’re right you can just attach the token to the tenant. Mostly was just suggesting a way to add data to the token without having to update it after create. With JWT you add data sometimes $token = $user->makeToken('Name');
$token->account_id = 1;
$token->team_id = 2;
$token->save(); In a model trait for example $model->account_id = auth()->user()->accessToken->account_id;
$model->team_id = auth()->user()->accessToken->team_id; |
Hi. I need this. Has it been implemented? |
Hi , I customized
And on the
Or you can customize the I hope it can help you, |
@Minhlong Did this work for you? How would a token holder read the 'shop_id' from the token? |
The shop_id is used to create token. It does not use to validate the token :). You can refer below flow:
|
Excelent! Thanks for posting. I used your example and it worked for me |
@Minhlong I see the shop_id is only added to the table via PersonalAccessToken, thanks |
Idea: adding a 3rd parameter to
createToken()
for custom columnsIf your token has additional scope or tenant information.. being able to pass it in like:
With an array merge.. would be convenient
Otherwise, an observer works or
$token->update($values)
on the returned tokenThe text was updated successfully, but these errors were encountered: