Meteor 中的默认设置不允许从客户端创建帐户,这在许多应用程序中出于安全目的是有意义的,但我正在构建一个博客,需要允许用户创建一个帐户,以便他们可以发表评论。
github、stackoverflow 和各种教程上的典型响应似乎建议将以下代码添加到您的文件中,客户端/服务器条件之外的任何位置,以便它可以在客户端和服务器上运行:
Accounts.config({
forbidClientAccountCreation: false
});
看起来很简单。我在 lib 文件夹中的文件 (configure.js) 中输入了这段代码,但终端中出现以下错误消息:
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.
该行“无法设置forbidClientAccountCreation
不止一次”似乎暗示问题源于多个包以某种方式重新声明相同的代码。
我有一些软件包,例如 account-ui、accounts-password、useraccounts:core 和 useraccounts:foundation,但 Meteor 似乎因信号冲突而不知所措(其他人也抱怨与 useraccounts:bootstrap 发生冲突。)不确定其中是否有任何一个是我的代码中冲突的直接根源,其他开发人员建议删除任何冲突的包,但这似乎是一个糟糕的解决方案。添加这些包是有原因的。应该有一种方法可以毫无问题地明确设置此变量。
我似乎无法找到合理的解决方案。想法?
使用时不能将其设置为 falseuseraccounts:core
包,因为该包将其设置为 true。这useraccounts
套件提供了一个默认允许用户创建帐户的 UI。您不能使用以下提供的 UIaccounts-ui
创建您的用户(也不使用Accounts.createUser()
在客户端上)同时使用useraccounts
suite.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)