403 Error when Creating User with Pre-Existing Email Address? [SOLVED]

My createUser function ordinarily works great, but today I found that if a user sends it an already-registered email address, it returns:

Isn’t it supposed to return an “Email already exists” message?

Here’s my client code:

            Accounts.createUser({
                first_name: name_first,
                last_name: name_last,
                email: email,
                password: password,
                profile: {
                    'home_state': home_state,
                    'agreesToTerms': agreesToTerms,
                }
            }, function (err) {
                if (err) {
                      [.....]
                } 
            });
        }

Here’s my server code:

Accounts.onCreateUser(async (options, user) => {
    debugger; // <= NEVER ACTIVATES
    console.log('check #1') // <= NEVER PRINTS
    [.....]
});
  • Is this a Meteor 3 anomaly?
  • Am I doing something wrong with async in Accounts.onCreateUser now that Accounts.onCreateUser is async?
  • How can I attempt to debug this?

I think it is because meteor now enforces ambiguousErrorMessages since meteor 3.

This prevents issues with user enumeration. You can set to false that on the accounts config on the server.

LOL! That’s funny.

I’m pretty sure my Accounts.onCreateUser function should be called by Meteor. :thinking:

Checkout the docs on the accounts config, maybe if you set that to false it might work as you expect.

Wait, you mean you’re serious? :slight_smile: I opened the docs page you linked and I don’t see ambiguousErrorMessages there yet.

Jaja yes I am. The options are a bit hidden.

Where can I find that? What is it hidden behind?

Wait, I see where it goes. Checking…

Holy frijoles – THAT WORKED!

How did you even know about that?

Nice. I have used it in the past, and read recently that it was now defaulting to true on production. Maybe it should have been more explicit as this is probably a breaking change.

1 Like

Does this mean the defaults change in dev vs production?

I was finding the same results in both dev and production, in both M2 and M3.

There appears to be a difference between M2 and M3. In M2 this setting apparently defaulted to false, and in M3 it apparently defaults to true.

The solution, for purposes of completeness for this thread, is:

Accounts.config({
    [.....]
    ambiguousErrorMessages: false 
});