Meteor:提供调用'createUser'结果的异常

时间:2018-01-20 00:09:04

标签: javascript reactjs meteor meteor-accounts meteor-react

已发布类似问题,但问题和解决方案与我的用例不太匹配。我使用React作为我的渲染引擎,使用Flow-Router作为我的路由器。

错误如下:

Exception in delivering result of invoking 'createUser': isArguments@http://localhost:3000/packages/es5-shim.js?hash=c070fc7aa1536cb75430d62c9dad8eaffe2b3716:1174:16 keys@http://localhost:3000/packages/es5-shim.js?hash=c070fc7aa1536cb75430d62c9dad8eaffe2b3716:1237:17 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16 ejson.js/EJSON.clone@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:689:3 ejson.js/EJSON.clone/<@http://localhost:3000/packages/ejson.js?hash=3af8c8d41c63ca01c1c9698a677bc5ae971ff3b2:690:16

有问题的代码是:

客户端:

onSubmit(e) {
    let input_valid = this.validateInput();
    if (!input_valid) {
        Materialize.updateTextFields();
    }

    if (input_valid) {
        Materialize.Toast.removeAll();
        let $toastContent = $('<div class="container" style="width: 200px"><div class="row">Creating account...</div><div class="row"><div class="progress"><div class="indeterminate"></div></div></div></div>');
        Materialize.toast($toastContent, 10000);
        let accountInfo = {
            first_name: this.state.first_name.value,
            last_name: this.state.last_name.value,
            email: this.state.email.value,
            password: this.state.password.value,
            phone_number: this.state.phone_number.value,
        };
        sleep(2000).then(() => {
            Accounts.createUser(accountInfo, function(err) {
                if (err) {
                    console.log("Error creating user");
                    console.log(err);
                    Materialize.Toast.removeAll();
                    Materialize.toast("There was an error creating your account. Please try again later. If this error persists, contact support.", 8000);
                } else {
                    console.log("Created user");
                    Meteor.loginWithPassword(email, password, function(err) {
                        if (err) {
                            console.log("Error logging in");
                            console.log(err);
                            Materialize.Toast.removeAll();
                            Materialize.toast("There was an error logging you in. Try logging in manually. If this error persists, contact support.", 8000);
                        } else {
                            console.log("Logged in!");
                            FlowRouter.go('/');
                        }
                    })
                }
            });
        });
    }

    e.preventDefault();
}

sleep函数只是在等待传入的时间后返回一个promise,以毫秒为单位。

服务器端:

import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';

Accounts.onCreateUser((options, user) => {
    // We still want the default hook's 'profile' behavior.
    if (options.profile) {
        user.profile = options.profile;
    }

    if (options.first_name) {
        user.first_name = options.first_name;
    }
    if (options.last_name) {
        user.last_name = options.last_name;
    }
    if (options.email) {
        user.email = options.email;
    }
    if (options.phone_number) {
        user.phone_number = options.phone_number;
    }

    return user;
});

不太清楚为什么会这样,所以任何帮助都会非常感激!

0 个答案:

没有答案