Skip to content

Commit

Permalink
feat: add docs for verification after login (#1692)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas authored Mar 26, 2024
1 parent ff051ef commit 0db1b91
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 3 deletions.
79 changes: 78 additions & 1 deletion docs/identities/sign-in/actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ created account to get access to your services, but instead can access all the f

## Show verification after successful registration

If you want to show the verification screen after registration, follow these steps:
If you want to show the verification screen after registration or login, follow these steps:

```mdx-code-block
<Tabs>
Expand Down Expand Up @@ -201,3 +201,80 @@ verification is enabled and the identity schema defines at least one verifiable
</TabItem>
</Tabs>
```

## Show verification after login if address is not verified yet

If you want to show the verification screen after login, if any of the user's addresses are not verified yet, add the
`verification` hook to the login after hooks.

Using the [Ory CLI](../../guides/cli/01_installation.mdx):

```shell
ory patch identity-config {project_id} \
--add '/selfservice/flows/registration/after/password/hooks=[{"hook": "verification"}]' \
--add '/selfservice/flows/registration/after/oidc/hooks=[{"hook": "verification"}]' \
--add '/selfservice/flows/registration/after/webauthn/hooks=[{"hook": "verification"}]'
```

To automatically show the verification screen in server rendered browser flows, add the `show_verification_ui` hook as well:

```mdx-code-block
<Tabs>
<TabItem value="Server rendered browser client">
```

Using the [Ory CLI](../../guides/cli/01_installation.mdx):

```shell
ory patch identity-config {project_id} \
--add '/selfservice/flows/registration/after/password/hooks=[{"hook": "show_verification_ui"}]' \
--add '/selfservice/flows/registration/after/oidc/hooks=[{"hook": "show_verification_ui"}]' \
--add '/selfservice/flows/registration/after/webauthn/hooks=[{"hook": "show_verification_ui"}]'
```

:::note

If your identity schema defines multiple verifiable addresses, Ory Identities redirects to the verification flow of only one of
the addresses.

:::

```mdx-code-block
</TabItem>
<TabItem value="SPA & Native clients">
```

For SPA and native clients, the response from the registration endpoint contains a `continue_with` field. This field lists
possible actions, the user might need to or can take next. For example, an object containing the ID of the verification flow
created as part of the registration flow:

```json
{
"continue_with": [
{
"action": "show_verification_ui",
"flow": {
"id": "d859f6af-1dfe-453e-9320-d572e10edeea",
"verifiable_address": "[email protected]"
}
}
// Other items
]
}
```

You can use this ID to fetch the verification flow information, using the
[`getVerificationFlow`](../../reference/api#tag/frontend/operation/getVerificationFlow) API method.

:::note

The response from the registration endpoint always contains the `continue_with` field with the `verification_ui` action, if
verification is enabled and the identity schema defines at least one verifiable address. Because of this, the
`show_verification_ui` hook has no effect for API and SPA clients.

:::

```mdx-code-block
</TabItem>
</Tabs>
```
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ To configure account verification, go to **Authentication** → **Email Verifica

:::caution

For SMS verification to work, you'll also need to configure a `courier_channel` with the ID set to `sms` via the CLI. See the
**Ory CLI** tab for more information.
For SMS verification to work, you'll also need to configure a courier channel with the ID set to `sms` via the CLI. See the
[courier documentation](../../emails-sms/10_sending-sms.mdx) for more information.

:::

Expand Down

0 comments on commit 0db1b91

Please sign in to comment.