Better AuthBA
Better Auth9mo ago
wz

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,
      },
    },
  },
})


Is there a way to write and execute it like this?
auth.api.signInEmail({
    body: {
      email: email,
      password: password,
      role: "roleA",
    },
  });
Was this page helpful?