Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self.build is not a function while UserSchema.register() #22

Open
f1nnix opened this issue Dec 20, 2015 · 0 comments
Open

self.build is not a function while UserSchema.register() #22

f1nnix opened this issue Dec 20, 2015 · 0 comments

Comments

@f1nnix
Copy link

f1nnix commented Dec 20, 2015

Error:

TypeError: self.build is not a function

Stack:

TypeError: self.build is not a function
    at UserSchema.register (/src/node_modules/passport-local-sequelize/lib/passport-local-sequelize.js:182:25)
    at /src/server/test/seed-users.js:11:12

The problem is caused by:

UserSchema.register = function (user, password, cb) {
        var self = this,
            fields = {};

        if (user instanceof UserSchema.Instance) {
            // Do nothing
        } else if (_.isString(user)) {
            // Create an instance of this in case user is passed as username
            fields[options.usernameField] = user;

            user = self.build(fields);
        } else if (_.isObject(user)) {
            // Create an instance if user is passed as fields
            user = self.build(user); // <===== THIS LINE
        }

Env:

root@c16383fbfd19:/src# node -v
v5.1.0

Babel-config:

{
  "optional": ["es7.decorators", "es7.classProperties", "es7.objectRestSpread"]
}

with require('babel/register')({});

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant