How can I access authenticated user in computed property ? #3260
krunaldodiya
started this conversation in
General
Replies: 1 comment
-
So in simple terms there is no direct way to access the auth object (which is specific to an HTTP request) in models since that's how Node works. There are no shared global state like threaded languages. However, it is possible using the Async local storage, which is documented here https://docs.adonisjs.com/guides/async-local-storage Here I am making an assumption that you are new to the Node ecosystem and hence expected it work more like a threaded environment. So I will suggest you to spend some time
And then only use Async local storage |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello there,
I am new in Adonis, will you please guide how can I get authenticated user info in @computed hook ?
Also is it possible to get auth user info in @afterFind() hooks ?
Basically I need to check if a Post is favorited by currently authenticated user or not
Beta Was this translation helpful? Give feedback.
All reactions