BA
Better Auth•4mo ago
kaas

[Not sure if bug] Admin plugin does not use the Infering Types

As title says Using the create user
const newUser = await authClient.admin.createUser({
name: "Test User",
password: "password123",
role: "user"
});
const newUser = await authClient.admin.createUser({
name: "Test User",
password: "password123",
role: "user"
});
Does not adhere to any custom fields made in auth.ts I've added
additionalFields: {
firstName: {
type: "string",
required: true,
},
lastName: {
type: "string",
required: true,
},``
additionalFields: {
firstName: {
type: "string",
required: true,
},
lastName: {
type: "string",
required: true,
},``
The only fields it seems to take into consideration is the pre-defined fields that are found in the docs
name: "Test User",
password: "password123",
role: "user"
name: "Test User",
password: "password123",
role: "user"
eg:
id: "0_XCvVtlUk4bLELI_mCQ-",
name: "undefined undefined",
emailVerified: false,
image: undefined,
createdAt: new Date("2024-11-01T20:41:18.890Z"),
updatedAt: new Date("2024-11-01T20:41:18.890Z"),
role: "user",
banned: undefined,
banReason: undefined,
banExpires: undefined,
lastName: undefined,
street: undefined,
zip: undefined,
city: undefined,
country: undefined,
phoneNumber: undefined,
lang: undefined,
id: "0_XCvVtlUk4bLELI_mCQ-",
name: "undefined undefined",
emailVerified: false,
image: undefined,
createdAt: new Date("2024-11-01T20:41:18.890Z"),
updatedAt: new Date("2024-11-01T20:41:18.890Z"),
role: "user",
banned: undefined,
banReason: undefined,
banExpires: undefined,
lastName: undefined,
street: undefined,
zip: undefined,
city: undefined,
country: undefined,
phoneNumber: undefined,
lang: undefined,
All fields are undefined, but they are parsed to the function correctly.
5 Replies
Unknown User
Unknown User•4mo ago
Message Not Public
Sign In & Join Server To View
kaas
kaasOP•4mo ago
Interesting. I assume this is for the username plugin. Should be added to docs!:-)
Unknown User
Unknown User•4mo ago
Message Not Public
Sign In & Join Server To View
kaas
kaasOP•4mo ago
That solves alot of issues for me - In using the same endpoint as sign up for normal users in my admin area to work around this - so your findings fix that. Because i auto sign in users after creation, an admin would be signed in as the newly created user🤯
Unknown User
Unknown User•4mo ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?