SaasCore Docs
  • Get Started
  • Configuration
    • Database
    • Stripe
      • Product ID and Price ID
      • API keys
      • Stripe Webhook
    • Emails
      • Cron Jobs
    • Claudinary
    • Chat plugin
    • Upstash Redis
    • OAuth with Google and GitHub
    • Subscription types and plans
    • Affiliate program
    • Google Analytics Api
  • Landing page
    • Header
    • Hero
      • Discount
      • AvatarCircles
    • Other components
  • Authentication Flow
    • For Admins
    • For Clients
      • OAuth
      • Credentials
    • For Affiliates
  • Payments
    • Payment Flow Scenarios
      • Scenario 1: Registered Client
      • Scenario 2: Direct Subscription from Home Page
      • Upgrading/Downgrading/Canceling Subscriptions
    • Pricing Table
  • Component Protection
  • Pending ...
Powered by GitBook
On this page
  • Scenario 1: Sign up/Sign in with Free Account
  • Scenario 2: Sign up as a New Client Who Has Just Subscribed to a Plan
  1. Authentication Flow
  2. For Clients

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.

PreviousOAuthNextFor Affiliates

Last updated 10 months ago