Preloading a relation for auth


#1

How would I go about preloading a relationship each time the authed user gets loaded?

I have a relationship team() on my User model.

Whenever an authenticated user accesses an endpoint I want to load their team relationship to use in various places.

How would I abstract the user.load('team') logic into like app hooks or something?

I tried using Context.onReady but that didn’t seem to work


#2

Create a middleware and put it after the auth middleware