Insites Docs Developers guide Data and UsersUsersSigning In a User Automatically after Sign Up

Signing In a User Automatically after Sign Up

Last updated on June 26, 2024.

This document guides you on adding automatic sign-in to a sign-up form so that a new user will be logged in right after account creation.

Prerequisites

To follow this tutorial, you must already have a working sign-up form, where a user can create a new account:
Creating a Sign-Up Form

Steps

Automatic sign-in after sign-up is a three-step process:

  • Step 1: Add key to sign up form
  • Step 2: Create GraphQL mutation
  • Step 3: Create form

Step 1: Add the 'callback_actions' Key to Sign Up Form

In your form configuration, add the key at the end (order doesn't matter) of the YML definition.

app/forms/sign_up.liquid

This code snippet executes the query.

Step 2: Create 'user_session_create' GraphQL Mutation

This mutation takes two obligatory arguments: email and password – both strings.

app/graphql/user_session_create.graphql

This calls the with the same arguments you received from the .

Step 3: Create the 'session_create_form' Form

is supported by the server, so you don't need to define anything – the server will handle user credentials and authenticate the user.

app/forms/session_create_form.liquid

Next Steps

Congratulations! You have set up automatic user login after sign up. You can now learn about logging out the user: Logging Out an Authenticated User.

Have a suggestion for this page?

Didn't quite find what you are looking for or have feedback on how we can make the content better then we would love to hear from you. Please provide us feedback and we will get back to you shortly.