mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-27 17:36:42 -05:00
fix(two-factor): add device trust param for backup code verification
This commit is contained in:
@@ -103,7 +103,22 @@ export const backupCode2fa = (options?: BackupCodeOptions) => {
|
||||
/**
|
||||
* Disable setting the session cookie
|
||||
*/
|
||||
disableSession: z.boolean().optional(),
|
||||
disableSession: z
|
||||
.boolean({
|
||||
description: "If true, the session cookie will not be set.",
|
||||
})
|
||||
.optional(),
|
||||
/**
|
||||
* if true, the device will be trusted
|
||||
* for 30 days. It'll be refreshed on
|
||||
* every sign in request within this time.
|
||||
*/
|
||||
trustDevice: z
|
||||
.boolean({
|
||||
description:
|
||||
"If true, the device will be trusted for 30 days. It'll be refreshed on every sign in request within this time.",
|
||||
})
|
||||
.optional(),
|
||||
}),
|
||||
use: [verifyTwoFactorMiddleware],
|
||||
},
|
||||
|
||||
@@ -96,15 +96,12 @@ export async function onSubscriptionUpdated(
|
||||
const plan = await getPlanByPriceId(options, priceId);
|
||||
|
||||
const referenceId = subscriptionUpdated.metadata?.referenceId;
|
||||
const subscriptionId = subscriptionUpdated.id;
|
||||
const customerId = subscriptionUpdated.customer.toString();
|
||||
let subscription = await ctx.context.adapter.findOne<Subscription>({
|
||||
model: "subscription",
|
||||
where: referenceId
|
||||
? [{ field: "referenceId", value: referenceId }]
|
||||
: subscriptionId
|
||||
? [{ field: "stripeSubscriptionId", value: subscriptionId }]
|
||||
: [],
|
||||
: [{ field: "stripeSubscriptionId", value: subscriptionUpdated.id }],
|
||||
});
|
||||
if (!subscription) {
|
||||
const subs = await ctx.context.adapter.findMany<Subscription>({
|
||||
|
||||
Reference in New Issue
Block a user