Meteor onCreateUser生成403 Signup Forbidden

时间:2015-07-09 19:25:35

标签: meteor

我已经看过onCreateUser的几个例子,用于手动注册用户,我可以告诉我所有的代码看起来都没问题,但是我在创建时仍然收到Signups forbidden [403]错误。我还根据http://docs.meteor.com/#/full/accounts_createuser查看了文档。谢谢大家的帮助。

以下是我的内容: ROOT>客户端> registration.js

    Template.registrationStep2.events({

        'submit form': function(e, template) {
            e.preventDefault();

                var institutionID = template.find('#institutionID').value;
                var institutionRole = template.find('#institutionRole').value;
                var institutionName = template.find('#institutionName').value;

                var login = template.find('#login').value;
                var firstName = template.find('#firstName').value;
                var lastName = template.find('#lastName').value;
                var email = template.find('#email').value;
                var password = template.find('#password').value;

                var profile = {
                    firstName: firstName,
                    lastName: lastName,
                    role: institutionRole,
                    institutionID: institutionID
                }

                Accounts.createUser({
                    username: login,
                    email: email,
                    password: password,
                    profile: profile
                }, function(error){
                    if (error){
                        Meteor.log.error("Error Creating User", error);
                    } else {

                        Session.set("flashType", "success");
                        Session.set("flashMessage", "Your account has been created.");

                        Router.go('registrationComplete');
                    }
                });


            } else {
                // alert("Need institution");
                $('#needInstitutionModal').modal('show');
            }
        }
    });

我安装了accounts-passwordaccounts-ui并更新到最新版本。

无论我做什么,我都会收到 错误

I20150709-13:43:17.545(-5)? (13:43:17) [ERROR] - Object: 
I20150709-13:43:17.546(-5)? {
I20150709-13:43:17.546(-5)?     "time": "2015-07-09T18:43:17.543Z",
I20150709-13:43:17.546(-5)?     "level": "ERROR",
I20150709-13:43:17.546(-5)?     "message": "Error Creating User",
I20150709-13:43:17.546(-5)?     "userId": null,
I20150709-13:43:17.546(-5)?     "additional": {
I20150709-13:43:17.546(-5)?         "error": 403,
I20150709-13:43:17.546(-5)?         "reason": "Signups forbidden",
I20150709-13:43:17.546(-5)?         "message": "Signups forbidden [403]",
I20150709-13:43:17.547(-5)?         "errorType": "Meteor.Error"
I20150709-13:43:17.547(-5)?     }
I20150709-13:43:17.547(-5)? }

1 个答案:

答案 0 :(得分:4)

想出来。 为了做到这一点,我不得不将Accounts.createUser函数移动到服务器端(服务器文件夹中的server.js端)并将其称为Meteor.method调用。