Sign in after registration
The session action is used to sign in the user after they successfully register. If the option to verify the email address
before allowing users to sign in with a password is enabled, the session action can be used one time to bypass this requirement.
For example, after the user successfully registers with a password, you can use the session action to sign them in immediately,
bypassing the requirement to verify their email address first. This allows the user to start using the application right away,
without having to wait for account verification. The user still has to verify their email address before their next password
sign-in.
The session action provides a convenient way to sign in users and control the flow of events in your application.
Ory Network automatically activates the session action when a user signs up using social sign-in, SAML, WebAuthn, passkeys, or a
one-time code. These users receive a session even if they are shown a verification screen while their address is still unverified.
Toggle action
This action modifies the HTTP response. As a result, no other hooks can be executed after the session action. If you want to
trigger multiple actions that modify the HTTP response in your setup, make sure that session is triggered last.
Follow these steps to configure automatic sign-in after password registration:
- Ory Console
- Ory CLI
- Go to Authentication → General in the Ory Console.
- In the Account access card, toggle Enable sign in after registration.
- Click Save changes.
If the password registration hooks don't already include session, append it with this command:
ory patch identity-config --project <project-id> --workspace <workspace-id> \
--add '/selfservice/flows/registration/after/password/hooks/-={"hook":"session"}'
Configuring a method-specific registration hook such as session overrides global after registration hooks for that method. If
you use global registration webhooks, add them to the password registration hooks as well before enabling session. See
trigger precedence.
Web browser registration
The hook sends a Set-Cookie HTTP header which contains the session cookie. The user is signed in immediately.
Using this job as part of your post-registration workflow makes your system vulnerable to Account Enumeration Attacks because a threat agent can distinguish between existing and non-existing accounts by checking if Set-Cookie was sent as part of the registration response.
Native app registration
When registration is performed through an API client (such as a mobile app), the hook returns the session token and the session
itself in the response body as application/json:
{
"session": {
"id": "..."
// ...
},
"session_token": "...",
"identity": {
"id": "..."
// ...
}
}