Using jwt decoded

Hi there.

In Server.ts after “jwt.verify” is done, I think it’s better to write this:

Therefore, it’s better to pass “req” object to the hooks as a context:

await this.externalHooks.run('workflow.afterCreate', [savedWorkflow, { req }]);

or

await this.externalHooks.run('workflow.afterUpdate', [workflow, { req }]);

and so on…

What do you think about this? If you think it’s okey, I can open a pull request.
Thanks

@jan , Do you have any opinion about this?

That is sadly hard to answer. You say that you think it is “better”. Really depends on what you have planned and why you want to make that change. Can you please provide some background on what exactly you have planned.

Generally, is it not a breaking change, and can see how it could be helpful for some use cases.

1 Like

Thanks @jan for the answer.

Let’s assume we have a user authentication system using auth0 with the help of Server.ts’ jwt. We must add/update our user information to db when a workflow is created or updated (Using external hooks). Since the workflow is the only variable which is passed to external hooks, we must pass extra variable - decoded user - to that.
But I believe the req object would be the better choice for passing to external hooks.

As I said our case is only for created/updated workflows. But we can pass this “req” object to all external hooks in Server.ts as a context.

Dear @jan , Happy new year :slight_smile:
Just wanted to follow up.