Credentials

Scenario 1: Sign up/Sign in with Free Account

Responsible File: action/sign-up.ts

Steps:

  1. Inputs Validation

  2. User Record Creation: Hash the password before saving.

  3. Verification Token Generation

  4. Send Verification Email:

    • User receives a link in the form: auth/sign-up?token=token_code

    • The link performs automatic validation and informs the user of the result (success or error).

Final Steps:

  1. ClientPlan Creation: In the function (actions/auth/new-email-verification.ts), handle the ClientPlan creation and call handleAfterSignupTasks().

Scenario 2: Sign up as a New Client Who Has Just Subscribed to a Plan

This scenario is similar to the OAuth-based scenario for new clients with subscription plans.

  1. PreClientPlan Table: Created at the Stripe webhook level to store temporary plan information.

  2. Token-based Link: Sent to the client for account creation.

    Link Format: example.com/auth/sign-up?token=token_code

  3. In the action/sign-up.ts file, handle the token and proceed to set up the client’s account in the setupUserAccount() function.

  4. Use the token to extract data from the PreClientPlan record and create the ClientPlan.

    await prisma.clientPlan.create({
        data: {
            userId,
            subscriptionPlan: existingPreClientPlan.plan,
            status: "ACTIVE",
            subscriptionType: existingPreClientPlan.subscriptionType,
            // ...other fields
        },
    });
  5. Finally, call handleAfterSignupTasks() to complete the process.

Last updated