scorpiusjs / scorpius

Modular admin solution built with Meteor
http://scorpiusjs.org
MIT License
34 stars 7 forks source link

Crash when creating default admin user Error: Match error: Expected string, got object #21

Closed avishaan closed 7 years ago

avishaan commented 7 years ago

Originally I wrote this for orionjs but it's still applicable to scorpius js. I'm currently dealing with this so anything I can do to help I'm more than happy to. But I need a fix really badly. Even if just a setting to stop auto creation of an admin user. The problem is when deploying this can look like a failed deployment which is very confusing

I get the following error

W20160926-01:09:52.035(-7)? (STDERR) Error: Match error: Expected string, got object
W20160926-01:09:52.035(-7)? (STDERR)     at exports.check (packages/check/match.js:34:1)
W20160926-01:09:52.036(-7)? (STDERR)     at Object.Roles.addUserToRoles (packages/nicolaslopezj_roles/roles_server.js:18:1)
W20160926-01:09:52.036(-7)? (STDERR)     at Object.<anonymous> (packages/orionjs:accounts/accounts_server.js:13:11)
W20160926-01:09:52.037(-7)? (STDERR)     at packages/matb33_collection-hooks/packages/matb33_collection-hooks.js:290:1
W20160926-01:09:52.037(-7)? (STDERR)     at Array.forEach (native)
W20160926-01:09:52.038(-7)? (STDERR)     at Function._.each._.forEach (packages/underscore/underscore.js:105:1)
W20160926-01:09:52.039(-7)? (STDERR)     at after (packages/matb33_collection-hooks/packages/matb33_collection-hooks.js:289:1)
W20160926-01:09:52.039(-7)? (STDERR)     at Object.<anonymous> (packages/matb33_collection-hooks/packages/matb33_collection-hooks.js:304:1)
W20160926-01:09:52.039(-7)? (STDERR)     at Object.CollectionHooks.extendCollectionInstance._.each.collection.(anonymous function) [as insert] (packages/matb33_collection-hooks/packages/matb33_collection-hooks.js:111:1)
W20160926-01:09:52.040(-7)? (STDERR)     at [object Object].insert (packages/mongo/collection.js:528:37)
=> Exited with code: 1

Looking at accounts_server.js https://github.com/orionjs/orion/blob/master/packages/accounts/accounts_server.js#L13 I see that the following line

Roles.addUserToRoles(curUserId, 'admin');

is being passed a user object instead of the userid which means that this line in file roles_server.js causes a failure since it's an object instead of a userid

check(userId, String);

I think the matb33 library (very outdated) might be the culprit. Honestly, I don't know that assigning the first created user as an admin is so important. Instead of that you can just be clear in the documentation that you need to add an admin user in a fixture. It's actually more reasonable than having an admin user created by default

loongmxbt commented 7 years ago

Same problem, find a similar issue https://github.com/scorpiusjs/scorpius/issues/17

rwatts3 commented 7 years ago

Is this based on a fresh install or an existing project ?

rwatts3 commented 7 years ago

Could you also post your packages file content.

loongmxbt commented 7 years ago

It's a brand new project with fresh install of Scorpius, and the packages are like this:

meteor-base@1.0.4             # Packages every Meteor app needs to have
mobile-experience@1.0.4       # Packages for a great mobile UX
mongo@1.1.12                   # The database Meteor supports right now
blaze-html-templates@1.0.4    # Compile .html files into Meteor Blaze views
reactive-var@1.0.10            # Reactive variable for tracker
jquery@1.11.9                  # Helpful client-side library
tracker@1.1.0                 # Meteor's client-side reactive programming library

standard-minifier-css@1.2.0   # CSS minifier run for production mode
standard-minifier-js@1.2.0    # JS minifier run for production mode
es5-shim@4.6.14                # ECMAScript 5 compatibility for older browsers.
ecmascript@0.5.8              # Enable ECMAScript2015+ syntax in app code
shell-server@0.2.1            # Server-side component of the `meteor shell` command

# autopublish@1.0.7             # Publish all data to the clients (for prototyping)
# insecure@1.0.7                # Allow all DB writes from clients (for prototyping)
scorpiusjs:core
twbs:bootstrap
fortawesome:fontawesome
scorpiusjs:bootstrap
kadira:flow-router
kadira:blaze-layout
scorpiusjs:file-attribute
scorpiusjs:summernote

session

What's missing?

rwatts3 commented 7 years ago

By any chance do you have Options.set('forbidClientAccountCreation', false) in your code anywhere ?

rwatts3 commented 7 years ago

Version 0.3.0_1 was just released to atmosphere. Please test and see if this resolves the problem.