mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 17:46:06 +00:00
fix(auth): start the cardless trial for social signups too
The trial is granted in the credentials signup route and on the verification link, and an account created by Google or GitHub goes through neither: the Prisma adapter writes it directly. Since checkout no longer offers a trial either, such an account reached a locked product and an immediate bill, which is the opposite of what the signup page promised it. The address is already proven at this point, because the signIn callback turns away an OAuth profile that reports its email as unverified, and the grant is idempotent, so nothing here can hand out a second trial.
This commit is contained in:
+10
-1
@@ -6,7 +6,7 @@ import { PrismaAdapter } from '@auth/prisma-adapter';
|
|||||||
import bcrypt from 'bcryptjs';
|
import bcrypt from 'bcryptjs';
|
||||||
import { db } from '@/lib/db';
|
import { db } from '@/lib/db';
|
||||||
import { ProjectMemberRole, WorkspaceMemberRole } from '@prisma/client';
|
import { ProjectMemberRole, WorkspaceMemberRole } from '@prisma/client';
|
||||||
import { hasBillingAccess } from '@/lib/billing';
|
import { hasBillingAccess, startCardlessTrial } from '@/lib/billing';
|
||||||
import { isInviteCodeRequired } from '@/lib/feature-flags';
|
import { isInviteCodeRequired } from '@/lib/feature-flags';
|
||||||
import { isEmailVerificationEnabled } from '@/lib/email-verification';
|
import { isEmailVerificationEnabled } from '@/lib/email-verification';
|
||||||
|
|
||||||
@@ -163,6 +163,15 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
|
|||||||
userId: user.id,
|
userId: user.id,
|
||||||
visitor: await readVisitorContextFromHeaders(),
|
visitor: await readVisitorContextFromHeaders(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// And the trial with it, for the same reason: the two places that grant it
|
||||||
|
// are the credentials signup route and the verification link, and a social
|
||||||
|
// signup goes through neither. Without this a Google account reaches a
|
||||||
|
// locked product and a checkout that no longer offers a trial, which is the
|
||||||
|
// opposite of what the signup page promised it. The address is already
|
||||||
|
// proven here: the signIn callback above turns away an OAuth profile that
|
||||||
|
// reports its email as unverified.
|
||||||
|
await startCardlessTrial(user.id);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user