2018-10-30 18:17:07 -03:00
|
|
|
const path = require('path');
|
|
|
|
require('dotenv').config({ path: path.resolve(__dirname, '../../../.env') });
|
|
|
|
const MongoClient = require('mongodb').MongoClient;
|
|
|
|
const ObjectId = require('mongodb').ObjectID;
|
|
|
|
const debug = require('debug');
|
|
|
|
|
|
|
|
const log = debug('fcc:tools:seedLocalAuthUser');
|
2019-02-16 08:48:52 +00:00
|
|
|
const { MONGOHQ_URL } = process.env;
|
2018-10-30 18:17:07 -03:00
|
|
|
|
|
|
|
function handleError(err, client) {
|
|
|
|
if (err) {
|
|
|
|
console.error('Oh noes!! Error seeding local auth user.');
|
|
|
|
console.error(err);
|
|
|
|
try {
|
|
|
|
client.close();
|
|
|
|
} catch (e) {
|
|
|
|
// no-op
|
|
|
|
} finally {
|
|
|
|
/* eslint-disable-next-line no-process-exit */
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-18 19:32:49 +00:00
|
|
|
MongoClient.connect(MONGOHQ_URL, { useNewUrlParser: true }, function(
|
|
|
|
err,
|
|
|
|
client
|
|
|
|
) {
|
|
|
|
handleError(err, client);
|
2018-10-30 18:17:07 -03:00
|
|
|
|
2019-02-18 19:32:49 +00:00
|
|
|
log('Connected successfully to mongo');
|
2018-10-30 18:17:07 -03:00
|
|
|
|
2019-02-18 19:32:49 +00:00
|
|
|
const db = client.db('freecodecamp');
|
|
|
|
const user = db.collection('user');
|
2018-10-30 18:17:07 -03:00
|
|
|
|
2019-02-18 19:32:49 +00:00
|
|
|
user.deleteOne({ _id: ObjectId('5bd30e0f1caf6ac3ddddddb5') }, err => {
|
|
|
|
handleError(err, client);
|
2018-10-30 18:17:07 -03:00
|
|
|
|
2019-02-18 19:32:49 +00:00
|
|
|
try {
|
|
|
|
user.insertOne({
|
|
|
|
_id: ObjectId('5bd30e0f1caf6ac3ddddddb5'),
|
|
|
|
email: 'foo@bar.com',
|
|
|
|
emailVerified: true,
|
|
|
|
progressTimestamps: [],
|
|
|
|
isBanned: false,
|
|
|
|
isCheater: false,
|
2019-03-01 12:58:34 +00:00
|
|
|
username: 'developmentuser',
|
2019-02-18 19:32:49 +00:00
|
|
|
about: '',
|
|
|
|
name: 'Development User',
|
|
|
|
location: '',
|
2019-08-19 19:17:53 +05:30
|
|
|
picture: 'https://github.com/identicons/camperbot.png',
|
2019-02-18 19:32:49 +00:00
|
|
|
acceptedPrivacyTerms: true,
|
|
|
|
sendQuincyEmail: false,
|
|
|
|
currentChallengeId: '',
|
|
|
|
isHonest: false,
|
|
|
|
isFrontEndCert: false,
|
|
|
|
isDataVisCert: false,
|
|
|
|
isBackEndCert: false,
|
|
|
|
isFullStackCert: false,
|
|
|
|
isRespWebDesignCert: false,
|
|
|
|
is2018DataVisCert: false,
|
|
|
|
isFrontEndLibsCert: false,
|
|
|
|
isJsAlgoDataStructCert: false,
|
|
|
|
isApisMicroservicesCert: false,
|
|
|
|
isInfosecQaCert: false,
|
|
|
|
is2018FullStackCert: false,
|
|
|
|
completedChallenges: [],
|
|
|
|
portfolio: [],
|
|
|
|
yearsTopContributor: [],
|
|
|
|
rand: 0.6126749173148205,
|
|
|
|
theme: 'default',
|
|
|
|
profileUI: {
|
|
|
|
isLocked: true,
|
|
|
|
showAbout: false,
|
|
|
|
showCerts: false,
|
|
|
|
showDonation: false,
|
|
|
|
showHeatMap: false,
|
|
|
|
showLocation: false,
|
|
|
|
showName: false,
|
|
|
|
showPoints: false,
|
|
|
|
showPortfolio: false,
|
|
|
|
showTimeLine: false
|
|
|
|
},
|
|
|
|
badges: {
|
|
|
|
coreTeam: []
|
|
|
|
},
|
|
|
|
isDonating: false,
|
|
|
|
emailAuthLinkTTL: null,
|
|
|
|
emailVerifyTTL: null
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
handleError(e, client);
|
|
|
|
} finally {
|
|
|
|
log('local auth user seed complete');
|
|
|
|
client.close();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|