fix(two-factor): add device trust param for backup code verification

This commit is contained in:
Bereket Engida
2025-03-02 19:55:52 +03:00
parent 1b9a7fb02d
commit f1dc201384
2 changed files with 17 additions and 5 deletions

View File

@@ -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],
},

View File

@@ -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>({