OAuth
Scenario 1: Sign up/Sign in with Free Account
This scenario applies if your web app offers a free plan or requires only account registration without any payment.
Responsible File: auth.ts
Callback Function: signIn()
Conditions:
A "Free Plan" must exist among your available plans.
Process:
A free account is setup by calling the
createUser
event in theauth.ts
file.This triggers the crucial
setupUserAccount()
function, which in this scenario executes:
Scenario 2: Sign up as a New Client Who Has Just Subscribed to a Plan
This is the most common scenario in SaaS applications.
Process:
When a new visitor subscribes to a plan for the first time, a
PreClientPlan
table is created at the Stripe webhook level to temporarily store plan information with a token.A link containing the token is sent to the new client to create their account.
Link Format:
example.com/auth/sign-up?token=token_code
In the
auth.ts
file, thecreateUser
event is triggered, invoking thesetupUserAccount()
function.The function searches for the
PreClientPlan
record using the token to retrieve data for creating the actualClientPlan
:The
handleAfterSignupTasks()
function is then called to complete the process.
Additional Details:
No Free Plan Available: If a free plan is not available, sign-up/sign-in is restricted except in the following cases:
Authenticating with an admin email (specified in the config file).
Authenticating as a client who has previously signed up.
Authenticating as a client who has already paid for their subscription plan.
Last updated