Cannot sign in if local user already exists
I cannot sign into my account if a local account with that email already exists, as it will throw The following fields contain error: emails. Can this be fixed?
Should it sign in as the existing user?
Option 1: set the subField: { name: 'email' } to use email as unique user id.
Option 2: use the userinfo option to update the sub field of the matching user before returning the userinfo.
Should it sign in as the existing user?
For us, yes, as we do not allow local user registrations. For other applications out there, likely not without additional security checks.
Option 2: use the
userinfooption to update thesubfield of the matching user before returning the userinfo.
What do you mean in Option 2? We already return the sub field value.
Well, it's good to return it, but if there is no user with that sub, a user will be created. If this is not what you want, you should make sure there is a user with that sub.
userinfo() {
const sub = ...
const email = ...
// pseudo code
const exists = payload.find({ collection: "users", where: email equals email })
if (exists.sub !== sub) payload.update(... exists.id ... { sub })
return { sub, email }
}