For the Registration `after` hooks (<Docs>) the d...
# talk-kratos
t
For the Registration
after
hooks (Docs) the documented usecase below doesn't appear to be possible:
Registration actions allow you to automate behavior in response to users registering in your application. For example, you can use Ory Actions to automatically create a user account in your database or add the user to your mailing list.
The identity response in the hook doesn't contain key information, instead it just contains placeholder data, such as no identity ID etc (full response in the thread), and so there isn't a way to be able to properly associate the Kratos Identity with our account service. Is this intentional, or should I raise as a bug?
This is the response from a successful registration
after
hook. As you can see, a handful of fields contain placeholder data (eg
identity.id = 00000000-0000-0000-0000-000000000000
Copy code
{
  "identity": {
    "created_at": "0001-01-01T00:00:00Z",
    "id": "00000000-0000-0000-0000-000000000000",
    "metadata_public": null,
    "recovery_addresses": [
      {
        "created_at": "0001-01-01T00:00:00Z",
        "id": "00000000-0000-0000-0000-000000000000",
        "updated_at": "0001-01-01T00:00:00Z",
        "value": "<snip>",
        "via": "email"
      }
    ],
    "schema_id": "default",
    "schema_url": "",
    "state": "active",
    "state_changed_at": "2023-09-04T16:37:50.561876646Z",
    "traits": {
      "email": "<snip>"
    },
    "updated_at": "0001-01-01T00:00:00Z",
    "verifiable_addresses": [
      {
        "created_at": "0001-01-01T00:00:00Z",
        "id": "00000000-0000-0000-0000-000000000000",
        "status": "pending",
        "updated_at": "0001-01-01T00:00:00Z",
        "value": "<snip>",
        "verified": false,
        "via": "email"
      }
    ]
  }
}
What's the recommended way of using these hooks for being able to associate an new identity with our internal account service?
Looking through the Kratos code, there does appear to be two internal hooks
PostRegistrationPrePersistHooks
&
PostRegistrationPostPersistHooks
. the
PostPersist
hook appears to contain the correct data, implying that
selfservice.flows.registration.after.hooks
runs as a PrePersist. How can I run this as a
PostPersist
?
s
I believe this is controlled by the
Copy code
response:
    parse: false
configuration option. Disallowing webhook response from modifying the identity should let it run after persist phase.
t
You're right, thank you so much! Been wracking my brain over that all morning!