wz
wz
BABetter Auth
Created by wz on 3/29/2025 in #help
Can I Add a User-Type Condition to the SQL WHERE Clause During Sign-in?
I have added a "role" field to the user model as follows. Is it possible to add a condition to the SQL WHERE clause to only include users with a specific "role" when signing in? I have looked through the documentation and source code, but I couldn't find a way to extend the SELECT conditions. Please let me know if there is a good way to do this.
export const auth = betterAuth({
user: {
additionalFields: {
role: {
type: "string",
required: true,
},
},
},
})
export const auth = betterAuth({
user: {
additionalFields: {
role: {
type: "string",
required: true,
},
},
},
})
Is there a way to write and execute it like this?
auth.api.signInEmail({
body: {
email: email,
password: password,
role: "roleA",
},
});
auth.api.signInEmail({
body: {
email: email,
password: password,
role: "roleA",
},
});
4 replies