fix: totp should default to app name if issuer isn't provided

This commit is contained in:
Bereket Engida
2024-11-14 09:47:13 +03:00
parent cbde1de713
commit cf298cccd4
2 changed files with 3 additions and 3 deletions

View File

@@ -22,7 +22,7 @@ export const twoFactor = (options?: TwoFactorOptions) => {
};
const totp = totp2fa(
{
issuer: options?.issuer || "better-auth",
issuer: options?.issuer,
...options?.totpOptions,
},
opts.twoFactorTable,

View File

@@ -18,7 +18,7 @@ export type TOTPOptions = {
/**
* Issuer
*/
issuer: string;
issuer?: string;
/**
* How many digits the otp to be
*
@@ -115,7 +115,7 @@ export const totp2fa = (options: TOTPOptions, twoFactorTable: string) => {
await ctx.context.password.checkPassword(user.id, ctx);
return {
totpURI: createTOTPKeyURI(
options?.issuer || "BetterAuth",
options.issuer || ctx.context.appName,
user.email,
Buffer.from(twoFactor.secret),
opts,