-
Hello, I made an app with a separate front end UI using VueJS and the Laravel Breeze Api as backend. I followed the documentation and implemented laravel-permissions. Upon login the frontend gets user information using this route: Route::middleware(['auth:sanctum'])->get('/user', function (Request $request) {
return $request->user();
}); What I want is that the returned object also includes user's role and permissions, without an additional route to call. |
Beta Was this translation helpful? Give feedback.
Answered by
loxK
May 24, 2023
Replies: 1 comment
-
I found that I can do this, if there is a better way to do it, tell me please: Route::middleware(['auth:sanctum'])->get('/user', function (Request $request) {
return [
'user' => $request->user(),
'roles' => $request->user()->getRoleNames(),
'permissions' => $request->user()->getAllPermissions(),
];
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
drbyte
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found that I can do this, if there is a better way to do it, tell me please: