diff --git a/docs/content/docs/plugins/2fa.mdx b/docs/content/docs/plugins/2fa.mdx index b1903c39..90d3394c 100644 --- a/docs/content/docs/plugins/2fa.mdx +++ b/docs/content/docs/plugins/2fa.mdx @@ -393,7 +393,7 @@ these are options for TOTP. default: 6, }, period: { - description: "The period for otp in seconds.", + description: "The period for totp in seconds.", type: "number", default: 30, }, @@ -411,9 +411,9 @@ these are options for OTP. type: "function", }, period: { - description: "The period for otp in seconds.", + description: "The period for otp in minutes.", type: "number", - default: 30, + default: 3, }, }} /> diff --git a/packages/better-auth/src/plugins/two-factor/index.ts b/packages/better-auth/src/plugins/two-factor/index.ts index ade69e17..c9fc93ce 100644 --- a/packages/better-auth/src/plugins/two-factor/index.ts +++ b/packages/better-auth/src/plugins/two-factor/index.ts @@ -296,7 +296,7 @@ export const twoFactor = (options?: TwoFactorOptions) => { */ deleteSessionCookie(ctx, true); await ctx.context.internalAdapter.deleteSession(data.session.token); - const maxAge = options?.otpOptions?.period || 60 * 5; // 5 minutes + const maxAge = (options?.otpOptions?.period ?? 3) * 60; // 3 minutes const twoFactorCookie = ctx.context.createAuthCookie( TWO_FACTOR_COOKIE_NAME, {