如何在 Meteor 中将 forbidClientAccountCreation 设置为 false? [英] How can I set forbidClientAccountCreation to false in Meteor?

查看:43
本文介绍了如何在 Meteor 中将 forbidClientAccountCreation 设置为 false?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

github、stackoverflow 和各种教程的典型响应似乎建议将以下代码添加到您的文件中,位于客户端/服务器条件之外的任何位置,以便它可以在客户端和服务器上运行:

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
});

看起来很简单.我在 lib 文件夹的文件 (configure.js) 中输入了这段代码,但终端中出现以下错误消息:

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.

不能多次设置 forbidClientAccountCreation"这一行似乎暗示问题源于多个包以某种方式重新声明相同的代码.

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.

我有几个包,例如 accounts-ui、accounts-password、useraccounts:core 和 useraccounts:foundation,但似乎 Meteor 被冲突信号淹没了(其他人也抱怨与 useraccounts:bootstrap 冲突).) 我不确定这些是否是我代码中冲突的直接来源,其他开发人员建议删除任何冲突的包,但这似乎是一个糟糕的解决方案.添加软件包是有原因的.应该有一种方法可以毫无问题地明确设置此变量.

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?

推荐答案

您不能在使用 useraccounts:core 包时将其设置为 false,因为该包将其设置为 true.useraccounts 套件提供了一个 UI,默认情况下应该允许用户创建帐户.在使用 useraccounts<时,您不能使用 accounts-ui 提供的 UI 创建您的用户(也不能在客户端上使用 Accounts.createUser())/code> 套件.

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.

这篇关于如何在 Meteor 中将 forbidClientAccountCreation 设置为 false?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆