<@U04UQ68083H> what's the best way to check if an ...
# ory-copilot
b
@chilly-king-10285 what's the best way to check if an account is verified in a SPA after receiving an identity?
c
A message from kapa.ai
In a Single Page Application (SPA), after receiving an identity, you can check if an account is verified by examining the response from the registration endpoint. This response contains a
continue_with
field which 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 might look like this:
Copy code
json {    "continue_with": [    {    "action": "show_verification_ui",    "flow": {    "id": "d859f6af-1dfe-453e-9320-d572e10edeea",    "verifiable_address": "[[email protected]](<https://www.ory.sh/cdn-cgi/l/email-protection>)"    }    }    // Other items    ]   }
You can use this ID to fetch the verification flow information, using the [
getVerificationFlow
](https://www.ory.sh/docs/reference/api#tag/frontend/operation/getVerificationFlow) API method. 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. Please note that the
show_verification_ui
hook has no effect for API and SPA clients. For more details, you can refer to the [Ory documentation](https://www.ory.sh/docs/identities/sign-in/actions#show-verification-after-successful-registration).
b
and how about on a none SPA application @chilly-king-10285
c
A message from kapa.ai
For non-SPA applications, the process is similar. After receiving an identity, you can check if an account is verified by examining the response from the registration endpoint. This response contains a
continue_with
field which 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 might look like this:
Copy code
json {{    "continue_with": [    {{    "action": "show_verification_ui",    "flow": {{    "id": "d859f6af-1dfe-453e-9320-d572e10edeea",    "verifiable_address": "[[email protected]](<https://www.ory.sh/cdn-cgi/l/email-protection>)"    }}    }}    // Other items    ]   }}
You can use this ID to fetch the verification flow information, using the [
getVerificationFlow
](https://www.ory.sh/docs/reference/api#tag/frontend/operation/getVerificationFlow) API method. 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. For more details, you can refer to the [Ory documentation](https://www.ory.sh/docs/identities/sign-in/actions#show-verification-after-successful-registration).
b
@chilly-king-10285 how about after receiving a session after login?
c
A message from kapa.ai
After receiving a session following a login, you can check if an account is verified by making a request to the
/sessions/whoami
endpoint. This endpoint will return the session data, which includes the identity of the user and the verification status of their email address. Here is an example of how to check for an active session with an Ory Session Token:
Copy code
bash curl -H "Authorization: Bearer {your-session-token}" \    "https://{project.slug}.<http://projects.oryapis.com/sessions/whoami|projects.oryapis.com/sessions/whoami>"
And here is an example of how to check for an active session with an Ory Session Cookie:
Copy code
bash curl -H "Cookie: ory_session_...=..." \    "https://{project.slug}.<http://projects.oryapis.com/sessions/whoami|projects.oryapis.com/sessions/whoami>"
The response will include a field
identity.verifiable_addresses[0].verified
which will be
true
if the account is verified and
false
otherwise. For more details, you can refer to the [Ory documentation](https://www.ory.sh/docs/identities/sign-in/check-session-token-cookie-api).
b
thought as much, just wanted to check. seems checking
identity.verifiable_addresses[0].verified
is going to be critical