network icon indicating copy to clipboard operation
network copied to clipboard

"after registration" hook is not fired

Open olofholmlund opened this issue 2 years ago • 2 comments

Preflight checklist

Ory Network Project

recursing-dirac-6i4w187k0d

Describe the bug

We have configured an action to fire after registration but the webhook is never fired.

I have tried with a simple "ping" webhook which does nothing more than ping my API to eliminate issues with the hook itself. This is the only configured action in the project, so no actions that would interfere.

We are using custom UI with the javascript SDK and not the default account experience, but our users are successfully registered and shows up in the identities list.

If I in the console disable the option Enable sign in after registration then the webhook is fired The option can be found at https://console.ory.sh/projects/current/authentication

By looking at the raw json config it seems that the automatically added session webhook interferes with the configured action.

Thanks

Reproducing the bug

  1. Create a project using custom UI (with ory elements/javascript sdk)

  2. Add "after registration" hook to ping some URL Skärmavbild 2023-11-23 kl  10 42 31

  3. Register a new user and the webhook is not fired.

(to fix) 4. disable Enable sign in after registration 5. Register new user, the webhook is now fired but user is not automatically signed in due to the option being disabled

Relevant log output

No response

Relevant configuration

No response

Version

Ory network (essential plan)

On which operating system are you observing this issue?

Ory Network

In which environment are you deploying?

Ory Network

Additional Context

No response

olofholmlund avatar Nov 23 '23 09:11 olofholmlund

Hi, I'm facing the same issue.

No webhook in the list of events is being delivered: image

When disabling the Enable sign in after registration it indeed works. image

But this impact the user experience.

Enabling sign in after registration back. It is working when method Password or OIDC are selected individually, if All is selected it does not work:

image

So I had to create two webhooks with the similar settings, one triggered on Password and the other on OIDC: image

That is working as expected: image

st3w4r avatar Mar 28 '24 13:03 st3w4r

Hello @olofholmlund

This is caused by the session hook, see the docs here: https://www.ory.sh/docs/actions/session

The session hook overwrites any other hooks that run after it which is why you don't see a response. In Ory Console it is the "Sign in after registration" setting. That setting is actually a hook, the "session hook".

The solution would be to put the session hook after the other one. So add the action to each auth method (oidc, password, webauthn) and then order it so the session hook comes last. See this screenshot Screenshot 2024-03-27 at 13 34 00

To order the hooks, export the configuration through the Ory CLI

and order it like so

        password:
          hooks:
          - config:
              body: https://storage.googleapis.com/bac-gcs-production/bar.jsonnet
              can_interrupt: false
              method: POST
              response:
                ignore: false
                parse: false
              url: https://webhook.site/foo
            hook: web_hook
          - hook: session

Then the webhook should work as expected.

Apologies for the weird behaviour here, we are currently working on making this work as expected out of the box. At the moment I would recommend to use the Ory CLI to edit registration hooks instead of the UI.

vinckr avatar Mar 28 '24 16:03 vinckr