hi - I was wondering if anyone had any experience ...
# talk-kratos
d
hi - I was wondering if anyone had any experience , or can point me to anything to read, regarding user registration with Kratos where the user needs to be invited to register? The kind of flow I’m looking for: • Potential new user is emailed a link to create an account. The link includes an invite code, which is used to validate the invitation link, and also contains a set of permissions that the new user should have (such as an organisation membership). The permissions are handled outside of Kratos. • User clicks the “create account” link in the email • System validates the invite code. ◦ If invalid, display an error • User completes signup process ◦ Kratos creates the new user ◦ Permissions described in the invitation code are granted to the new user I presume this could be accomplished with hooks. We’re looking at replacing an existing system. Thanks!
I guess what I’m looking to understand is how we can pass extra information (an invite code) through the registration process to the hook?
b
Hi, this could be possible by using identity
traits
, but those would be visible (and editable, after the registration) to the user in the default settings UI. You could of course filter those out, if you build the UI on your own. And if you just need to verify the code during the registration, this should not be an issue. In essence, you would set the identity schema to include
Copy code
"invitationCode": {
          type: string,
          title: "Invitation Code"
        }
This would then be included in any registration flow’s nodes in Kratos and is a mandatory field for the user to fill out during registration. Then you could add a hook to the registration, and include a JSONNET configuration that includes
ctx.identity.traits.invitationCode
and that calls your backend. You should be able to set
can_interrupt
to
true
, so your backend can decide if the invitation code is valid, or not. You can read more on that here: https://www.ory.sh/docs/kratos/hooks/configure-hooks#webhooks