Credentials
Scenario 1: Sign up/Sign in with Free Account
Responsible File: action/sign-up.ts
Steps:
Inputs Validation
User Record Creation: Hash the password before saving.
Verification Token Generation
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:
ClientPlan Creation: In the function (
actions/auth/new-email-verification.ts
), handle theClientPlan
creation and callhandleAfterSignupTasks()
.
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.
PreClientPlan Table: Created at the Stripe webhook level to store temporary plan information.
Token-based Link: Sent to the client for account creation.
Link Format:
example.com/auth/sign-up?token=token_code
In the
action/sign-up.ts
file, handle the token and proceed to set up the client’s account in thesetupUserAccount()
function.Use the token to extract data from the
PreClientPlan
record and create theClientPlan
.await prisma.clientPlan.create({ data: { userId, subscriptionPlan: existingPreClientPlan.plan, status: "ACTIVE", subscriptionType: existingPreClientPlan.subscriptionType, // ...other fields }, });
Finally, call
handleAfterSignupTasks()
to complete the process.
Last updated