v1.4 + Postgres: id: "user_id" mapping ignored in Email OTP
1. What's the issue:
The
emailOTP plugin ignores the global user.fields.id mapping (e.g., id: "user_id") when using the Postgres adapter in v1.4.1 (and 1.4.0-beta.20). It attempts to query the id column directly, causing a crash if the database uses a custom primary key name.
Unlike other plugins (e.g., twoFactor), the emailOTP plugin does not expose a schema configuration option, so it is impossible to manually correct the mapping as a workaround (as suggested in issue 4066 ).
1.1 What I've Tried:
- Downgrading: Issue persists in beta versions.
- Duplicate Column: Adding a real id column works but is effectively duplicate state.
- Updatable View: I am currently using a View (auth_users) to alias user_id -> id as a workaround, but this is heavy-handed.
2. Error Messages:
3. How to Reproduce:
1. Use a Postgres database where the user table has a custom primary key (e.g., user_id) and no id column.
2. Configure betterAuth with the Postgres adapter and the field mapping:
3. Add the emailOTP plugin.
4. Trigger an OTP verification flow.
5. Result: The server crashes with the error above because it queries id instead of user_id.0 Replies