twoFactorTable

Is it still possible to set twoFactorTable? I'm not able to find the function under the server config but is see the others:
issuer: "issuer-name",
skipVerificationOnEnable: true,
otpOptions: {
async sendOTP({user, otp}, request) {
// send otp to user
},
period: 30
},
totpOptions: {}
issuer: "issuer-name",
skipVerificationOnEnable: true,
otpOptions: {
async sendOTP({user, otp}, request) {
// send otp to user
},
period: 30
},
totpOptions: {}
11 Replies
Ping
Ping3mo ago
Hey can you elaborate? I'm not too sure I understand your question
rocketkittens
rocketkittensOP3mo ago
the database table for the two factor plugin, i want to change the name, however the option as per the documentation to change it is unavailable
Server twoFactorTable: The name of the table that stores the two factor authentication data. Default: twoFactor.
https://www.better-auth.com/docs/plugins/2fa
Two-Factor Authentication (2FA) | Better Auth
Enhance your app's security with two-factor authentication.
rocketkittens
rocketkittensOP3mo ago
using the command npx @better-auth/cli generate actually generated table named "two_factor" in the schema, not twoFactor
colin
colin2mo ago
Having the same issue. Did you manage to figure this out? I defined the schema for my TwoFactor table via the plugin's schema option. But still having issues with a bunch of API calls to the /two-factor endpoint.
Ping
Ping2mo ago
Are you using Drizzle?
rocketkittens
rocketkittensOP2mo ago
yes
Ping
Ping2mo ago
our schema gen will generate table names lowercased, but technically speaking the expected table name is twoFactor. When using the drizzle adapter, we look at your drizzle schema rather than relying on expected table names So using the drizzle schema gen variable name will be twoFactor but the name for the db will be two_factor
rocketkittens
rocketkittensOP2mo ago
i wanted to change the db table name
Ping
Ping2mo ago
you should be able to change the drizzle schema directly without chaning anything to do with better-auth
Ping
Ping2mo ago
Just change this part tho
No description
colin
colin2mo ago
Thank you. 👍. My specific issue was that twoFactorEnabled in my user table is named, two_factor_enabled. I managed to resolve my issue by defining this change in the twoFactor plugin's schema configuration option.

Did you find this page helpful?