I was tasked with importing a set of users into a live Meteor app hosted on Digital Ocean. The user data is stored in a JSON file. Due to the constraints of sshing into the Digital Ocean console, my approach is to run a JS script on the server from the mongo console.
Each user JSON object contains a BCRYPT password hash. Since we would like to keep the same password for each user during the import, I am using my local environment to create a user from the mongo console using the following script:
var user = {
"id": 773,
"firstName":"Paul",
"lastName":"DeJoe",
"companyName":"Ecquire",
"username":"paul@ecquire.com",
"guid":"d6810b32-8f11-4f5c-89c6-774ee59967a6",
"planUuid":"2e94b6ca8d340630897a0d4d988e7b06",
"joinDate":"2015-05-05 21:11:48",
"active":"true",
"admin":"false",
"purchaser":"true",
"services": { "bcrypt": {"password":"hashGoesHere"} }
};
function createUser(data) {
db.users.insert(data);
}
createUser(user);
The problem I am encountering is with regards to passwords. When I retrieve the record from the mongo console, I see the hash. However, when attempting to run:
Meteor.loginWithPassword();
I keep getting a 403 incorrect password error. Does anyone have any suggestions or perhaps another method to do this import?