feat(tools): add fully certified development user (#40181)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
const fullyCertifiedUser = require('./certifiedUserData');
|
||||
|
||||
const path = require('path');
|
||||
require('dotenv').config({ path: path.resolve(__dirname, '../../../.env') });
|
||||
const MongoClient = require('mongodb').MongoClient;
|
||||
@ -26,6 +28,122 @@ function handleError(err, client) {
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-disable max-len */
|
||||
const authUser = {
|
||||
_id: ObjectId('5bd30e0f1caf6ac3ddddddb5'),
|
||||
email: 'foo@bar.com',
|
||||
emailVerified: true,
|
||||
progressTimestamps: [],
|
||||
isBanned: false,
|
||||
isCheater: false,
|
||||
username: 'developmentuser',
|
||||
about: '',
|
||||
name: 'Development User',
|
||||
location: '',
|
||||
picture: defaultUserImage,
|
||||
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,
|
||||
isQaCertV7: false,
|
||||
isInfosecCertV7: false,
|
||||
is2018FullStackCert: false,
|
||||
isSciCompPyCertV7: false,
|
||||
isDataAnalysisPyCertV7: false,
|
||||
isMachineLearningPyCertV7: false,
|
||||
completedChallenges: [],
|
||||
portfolio: [],
|
||||
yearsTopContributor: envVariables.includes('--top-contributor')
|
||||
? ['2017', '2018', '2019']
|
||||
: [],
|
||||
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: envVariables.includes('--donor'),
|
||||
emailAuthLinkTTL: null,
|
||||
emailVerifyTTL: null
|
||||
};
|
||||
const blankUser = {
|
||||
_id: ObjectId('5bd30e0f1caf6ac3ddddddb9'),
|
||||
email: 'bar@bar.com',
|
||||
emailVerified: true,
|
||||
progressTimestamps: [],
|
||||
isBanned: false,
|
||||
isCheater: false,
|
||||
username: 'twaha',
|
||||
about: '',
|
||||
name: 'Development User',
|
||||
location: '',
|
||||
picture: defaultUserImage,
|
||||
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,
|
||||
isQaCertV7: false,
|
||||
isInfosecCertV7: false,
|
||||
is2018FullStackCert: false,
|
||||
isSciCompPyCertV7: false,
|
||||
isDataAnalysisPyCertV7: false,
|
||||
isMachineLearningPyCertV7: 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
|
||||
};
|
||||
|
||||
MongoClient.connect(MONGOHQ_URL, { useNewUrlParser: true }, (err, client) => {
|
||||
handleError(err, client);
|
||||
|
||||
@ -34,140 +152,42 @@ MongoClient.connect(MONGOHQ_URL, { useNewUrlParser: true }, (err, client) => {
|
||||
const db = client.db('freecodecamp');
|
||||
const user = db.collection('user');
|
||||
|
||||
user.deleteMany(
|
||||
{
|
||||
_id: {
|
||||
$in: [
|
||||
ObjectId('5bd30e0f1caf6ac3ddddddb5'),
|
||||
ObjectId('5bd30e0f1caf6ac3ddddddb9')
|
||||
]
|
||||
}
|
||||
},
|
||||
err => {
|
||||
if (process.argv[2] === 'certUser') {
|
||||
user.deleteOne({ _id: ObjectId('5fa2db00a25c1c1fa49ce067') }, err => {
|
||||
handleError(err, client);
|
||||
|
||||
try {
|
||||
user.insertOne({
|
||||
_id: ObjectId('5bd30e0f1caf6ac3ddddddb5'),
|
||||
email: 'foo@bar.com',
|
||||
emailVerified: true,
|
||||
progressTimestamps: [],
|
||||
isBanned: false,
|
||||
isCheater: false,
|
||||
username: 'developmentuser',
|
||||
about: '',
|
||||
name: 'Development User',
|
||||
location: '',
|
||||
picture: defaultUserImage,
|
||||
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,
|
||||
isQaCertV7: false,
|
||||
isInfosecCertV7: false,
|
||||
is2018FullStackCert: false,
|
||||
isSciCompPyCertV7: false,
|
||||
isDataAnalysisPyCertV7: false,
|
||||
isMachineLearningPyCertV7: false,
|
||||
completedChallenges: [],
|
||||
portfolio: [],
|
||||
yearsTopContributor: envVariables.includes('--top-contributor')
|
||||
? ['2017', '2018', '2019']
|
||||
: [],
|
||||
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: envVariables.includes('--donor'),
|
||||
emailAuthLinkTTL: null,
|
||||
emailVerifyTTL: null
|
||||
});
|
||||
|
||||
user.insertOne({
|
||||
_id: ObjectId('5bd30e0f1caf6ac3ddddddb9'),
|
||||
email: 'bar@bar.com',
|
||||
emailVerified: true,
|
||||
progressTimestamps: [],
|
||||
isBanned: false,
|
||||
isCheater: false,
|
||||
username: 'twaha',
|
||||
about: '',
|
||||
name: 'Development User',
|
||||
location: '',
|
||||
picture: defaultUserImage,
|
||||
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,
|
||||
isQaCertV7: false,
|
||||
isInfosecCertV7: false,
|
||||
is2018FullStackCert: false,
|
||||
isSciCompPyCertV7: false,
|
||||
isDataAnalysisPyCertV7: false,
|
||||
isMachineLearningPyCertV7: 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
|
||||
});
|
||||
user.insertOne(fullyCertifiedUser);
|
||||
} catch (e) {
|
||||
handleError(e, client);
|
||||
} finally {
|
||||
log('local auth user seed complete');
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
} else {
|
||||
user.deleteMany(
|
||||
{
|
||||
_id: {
|
||||
$in: [
|
||||
ObjectId('5bd30e0f1caf6ac3ddddddb5'),
|
||||
ObjectId('5bd30e0f1caf6ac3ddddddb9')
|
||||
]
|
||||
}
|
||||
},
|
||||
err => {
|
||||
handleError(err, client);
|
||||
|
||||
try {
|
||||
user.insertOne(authUser);
|
||||
user.insertOne(blankUser);
|
||||
} catch (e) {
|
||||
handleError(e, client);
|
||||
} finally {
|
||||
log('local auth user seed complete');
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user