Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set forbidClientAccountCreation to false in Meteor?

The default setting in Meteor does not allow account creation from the Client, which makes sense for security purposes in many applications, but I am building a blog and need to allow users to create an account so they can leave comments.

The typical response on github, stackoverflow, and various tutorials seems to suggest adding the following code to your files, anywhere outside of the client/server conditionals, so that it can run on both client AND server:

Accounts.config({
  forbidClientAccountCreation: false
});

Seems simple enough. I entered this bit of code in a file (configure.js) in my lib folder, but the following error message appears in the Terminal:

W20150925-19:52:17.568(9)? (STDERR) /Users/Eric/.meteor/packages/meteor-tool/.1.1.4.2l3p0l++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150925-19:52:17.568(9)? (STDERR)                         throw(ex);
W20150925-19:52:17.568(9)? (STDERR)                               ^
W20150925-19:52:17.627(9)? (STDERR) Error: Can't set `forbidClientAccountCreation` more than once
W20150925-19:52:17.627(9)? (STDERR)     at packages/accounts-base/accounts_common.js:95:1
W20150925-19:52:17.627(9)? (STDERR)     at Array.forEach (native)
W20150925-19:52:17.627(9)? (STDERR)     at Function._.each._.forEach (packages/underscore/underscore.js:105:1)
W20150925-19:52:17.628(9)? (STDERR)     at Object.Accounts.config (packages/accounts-base/accounts_common.js:92:1)
W20150925-19:52:17.628(9)? (STDERR)     at app/lib/configure.js:1:45
W20150925-19:52:17.628(9)? (STDERR)     at app/lib/configure.js:5:3
W20150925-19:52:17.628(9)? (STDERR)     at /Users/Eric/pilgrim/.meteor/local/build/programs/server/boot.js:222:10
W20150925-19:52:17.628(9)? (STDERR)     at Array.forEach (native)
W20150925-19:52:17.628(9)? (STDERR)     at Function._.each._.forEach (/Users/Eric/.meteor/packages/meteor-tool/.1.1.4.2l3p0l++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150925-19:52:17.628(9)? (STDERR)     at /Users/Eric/pilgrim/.meteor/local/build/programs/server/boot.js:117:5
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.

The line "Can't set forbidClientAccountCreation more than once" seems to imply that the problem is stemming from multiple packages reasserting this same code in some manner.

I have a few packages such as accounts-ui, accounts-password, useraccounts:core, and useraccounts:foundation, but it appears that Meteor gets overwhelmed with conflicting signals (others have complained of a conflict with useraccounts:bootstrap as well.) I'm not certain if any of these are a direct source of conflict in my code, and other developers suggest removing any conflicting packages, but that seems like a poor solution. The packages were added for a reason. There should be a way to definitively set this variable without issue.

I can't seem to find a reasonable solution to this. Thoughts?

like image 623
Eric Follows Avatar asked Jan 31 '26 02:01

Eric Follows


1 Answers

You can't set it to false while using the useraccounts:core package because that package sets it to true. The useraccounts suite provides a UI that should allow users to create accounts by default. You can't use the UI provided by accounts-ui to create your users (nor use Accounts.createUser() on the client) while using the useraccounts suite.

like image 159
Dean Brettle Avatar answered Feb 02 '26 09:02

Dean Brettle