Bug with admin plugin and renamed fields

I'm using the admin plugin, which adds a "role" field, I wanted to rename it "better_auth_role", so in the BetterAuth conf I did eg
user: {
modelName: "usersTable",
fields: {
emailVerified: "email_verified",
createdAt: "created_at",
updatedAt: "updated_at",
role: "better_auth_role", // admin plugin
banReason: "ban_reason", // admin plugin
banExpires: "ban_expires", // admin plugin
},
...
user: {
modelName: "usersTable",
fields: {
emailVerified: "email_verified",
createdAt: "created_at",
updatedAt: "updated_at",
role: "better_auth_role", // admin plugin
banReason: "ban_reason", // admin plugin
banExpires: "ban_expires", // admin plugin
},
...
but when trying to create a user with auth.api.createUser it complains The field "role" does not exist in the "usersTable" schema. Please update your drizzle schema or re-generate using "npx @better-auth/cli generate so it correctly saw that I renamed my table to usersTable (also it works for the other fields like emailVerified, etc) but it seems the admin plugin fields are not translated?
3 Replies
bekacru
bekacru4w ago
change the fields within the admin plugin instead
mael
maelOP3w ago
there is indeed a fields in the admin plugin config that can be overriden

Did you find this page helpful?