Repository navigation
Conversation
The action keys have been action.postFirstFactorVerification and action.postSignIn since Actions shipped. The inlineHook.* keys never existed, so API calls using them fail.
Document the Pre-register Action: when it runs, its event and result, what end users see when a registration is denied, an email validation example, failure behavior, and audit logs. Add it to the Actions overview and configuration page, and link it from the email blocklist.
Deploying logto-docs-tutorials with
|
| Latest commit: |
a3930ef
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c67df00d.logto-docs-tutorials.pages.dev |
| Branch Preview URL: | https://wangsijie-pre-register-actio.logto-docs-tutorials.pages.dev |
Deploying logto-docs with
|
| Latest commit: |
a3930ef
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://815f364c.logto-docs.pages.dev |
| Branch Preview URL: | https://wangsijie-pre-register-actio.logto-docs.pages.dev |
|
|
||
| ## Monitor executions \{#monitor-executions} | ||
|
|
||
| Each run creates an `Action.PreRegister` [audit log](/developers/audit-logs) event. To show which sign-up was evaluated, it keeps the interaction event, verification types, application ID, the user's `username`, `primaryEmail`, and `primaryPhone`, and the decision. It does not keep the rest of the profile, the request context, or the deny message returned by the script. |
There was a problem hiding this comment.
This isn't quite right: the audit log middleware prepends the request's ip, userAgent, and userAgentParsed to every log entry, and the Action.PreRegister entry is created with the default options, so it does carry them. Only the event's own request field is left out of the logged event.
Since this page has a privacy note, maybe something like:
… It does not copy the rest of the profile, the event's
requestfield, or the deny message returned by the script. Like every audit log entry, it records the IP address and user agent of the request.
| | Pre-register | Fail the registration. | Continue the registration as if the Action had allowed it. | | ||
|
|
||
| For Post sign-in, a malformed or unsupported return value always fails the sign-in, even when `allow` is selected. Validate every success path in your script and return an explicit supported result or no-op. | ||
| For Post sign-in and Pre-register, a malformed or unsupported return value always fails the sign-in or registration, even when `allow` is selected. Validate every success path in your script and return an explicit supported result or no-op. |
There was a problem hiding this comment.
Related: the Supported user patch section above still opens with "An Action can return only these user fields", which no longer holds for Pre-register. Its result guard is strict, so { action: 'allow', user: { ... } } is an invalid result. Dry runs skip result validation, so a script like that passes Run test and then fails every registration with action.general, whatever the error policy.
Maybe scope that sentence, e.g. "A Post first-factor verification or Post sign-in Action can return only these user fields. A Pre-register Action cannot change the user and returns only allow or deny."
| | { | ||
| action: 'deny'; | ||
| // Plain text shown to the end user, up to 256 characters. | ||
| message?: string; |
There was a problem hiding this comment.
nit: a message over 256 characters isn't truncated. The whole result becomes invalid, and the registration fails with action.general instead of action.registration_denied. Worth a few words here, e.g. // Plain text shown to the end user, up to 256 characters. A longer message makes the result invalid.
| throw new Error('ZeroBounce validation failed'); | ||
| } | ||
|
|
||
| if (['invalid', 'spamtrap', 'abuse', 'do_not_mail'].includes(result.status)) { |
There was a problem hiding this comment.
nit: ZeroBounce's do_not_mail also covers role-based addresses such as sales@, info@, and contact@ (sub_status: 'role_based'), which are deliverable. Apps that copy this would turn away teams signing up with a shared address. Maybe add a line after the example noting that, and that result.sub_status can be checked to let role-based addresses through.
charIeszhao
left a comment
There was a problem hiding this comment.
Left a few additional notes inline. One small optional nit on a file outside this diff:
docs/developers/README.mdx(line 43): the Actions card description still reads "Run synchronous custom code in the authentication flow to migrate or enrich users." — could also mention screening registrations.
| 1. Navigate to <CloudLink to="/actions">Console > Actions</CloudLink>. | ||
| 2. Select **Post first-factor verification** or **Post sign-in**. | ||
| 2. Select **Post first-factor verification**, **Post sign-in**, or **Pre-register**. | ||
| 3. Implement the `runAction` function in the script editor. |
There was a problem hiding this comment.
Related to Implement runAction (line 32 below): it currently reads:
To decline or continue without a user update, return the no-op value supported by the specific action type.
For Pre-register, returning a no-op (undefined, null, {}) allows registration rather than declining it—declining requires explicitly returning { action: 'deny' }. Worth rewording slightly (e.g. pointing to each action type's reference page for no-op vs. deny behavior) so readers don't mistakenly return undefined expecting a denial.
|
|
||
| - `Action.PostFirstFactorVerification` | ||
| - `Action.PostSignIn` | ||
| - `Action.PreRegister` |
There was a problem hiding this comment.
Let's also add Action.PreRegister (Execute Pre-register Action) to the ## Actions table in docs/developers/audit-logs/event-types.mdx (lines 35–41), which currently only lists Action.PostFirstFactorVerification and Action.PostSignIn.
| | ------------------------------------------ | -------------------------------------------------------------------------- | ----------------------------------------------------------------- | | ||
| | Execution | Synchronous and inline with authentication | Asynchronous and outside the authentication request | | ||
| | Can affect the current authentication flow | Yes | No | | ||
| | Can modify a user from its result | Yes, using the supported user patch | Not directly; the receiver can call the Management API separately | |
There was a problem hiding this comment.
nit: since Pre-register cannot modify a user, maybe qualify this lightly as "Yes, for sign-in Actions, using the supported user patch".
Summary
Document the Pre-register Action added in logto-io/logto#10082.
developers/actions/pre-register: when the Action runs (every Experience API registration method, after Logto's own registration checks) and when it doesn't, the event payload, theallowanddenyresults, what end users and custom UIs see onaction.registration_denied, a ZeroBounce email validation example, the error policies, and what theAction.PreRegisteraudit log keeps. It also notes that the event sends a prospective user's email and IP to whatever service the script calls.A separate commit fixes the action keys. The docs used
inlineHook.postFirstFactorVerificationandinlineHook.postSignInas "retained for backward compatibility", but every release since Actions shipped (v1.43.0) usesaction.postFirstFactorVerificationandaction.postSignIn. TheinlineHook.*keys never existed, so API calls that used them failed.