I have an API in .NET with an EF interceptor. The authentication of my API is done through JWT and I have an audit in my database of who has made the changes and at what moment.
The question is that I inject my service to retrieve the user id from the JWT as Scopen as I need the HTTP context.
That said, I needed to implement a Hangfire for tasks that can be triggered by an admin user. But the hanfire does not have an http context as its scope is terminated when the http request ends, and the http request just launches the hangfire task and gives a response before the task ends.
The question is that since I don’t have http context I don’t have the service to extract the id and I can’t inject it in the EF interceptor.

I would be grateful if you could help me.

Translated with DeepL.com (free version)