pqx994
pqx994

Reputation: 340

Error: Username already exists [403] Meteor

I have manually created a user on a meteor app with Accounts.createUser and have disabled sign ups so this is the only user. This worked until I restarted the server and started getting this error:

Error: Username already exists. [403]

I have Accounts.createUser under if (Meteor.isServer), I suspect where I created the user may be the issue. Thoughts?

Upvotes: 1

Views: 1477

Answers (1)

Tarang
Tarang

Reputation: 75945

You're running Accounts.createUser every time you run your app.

Try doing this, which will only create a user if there are none in your collection.

if(Meteor.isServer) {
    if(!Meteor.users.findOne()) {

        Accounts.createUser(....)

    }
}

Upvotes: 2

Related Questions