Out of the box, the adonis inertia.js config file had this section of code:
sharedData: {
user: (ctx) => ctx.inertia.always(() => ctx.auth.user),
},
But in my vue components, when I add user to defineProps it is undefined.
What am I missing? The documentation on the AdonisJS site doesn't go into much detail.
Join The Discussion! (3 Replies)
Please sign in or sign up for free to join in on the dicussion.
tomgobich
Hi Ryan!
The authenticated user isn't populated until you tell AdonisJS to populate it. This can be done using the
auth
middleware,silent_auth
middleware, or manually callingauth.check()
as needed. You're most likely missing one of those.Note that you also need to specify a serialized type for your Lucid Models using either casting or DTOs.
Please sign in or sign up for free to reply
ryan-clare
Thank you! Yes, I found from another forum that I was not using the auth middleware with my route. I added it, and now the user shows up as expected.
Please sign in or sign up for free to reply
tomgobich
Awesome! I'm glad to hear you were able to get it figured out! 😊
Please sign in or sign up for free to reply