From bc36a79b94f4202e3cec45fd838c3d310eaf584c Mon Sep 17 00:00:00 2001 From: Bharathvaj Date: Thu, 3 May 2018 00:45:33 +0530 Subject: [PATCH] Move examples username and password to .env file (#556) * Move examples username and password to .env file * Update README.md * Update examples.js * Update examples.js --- README.md | 3 +++ server/examples.js | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 74b9c9fd..13042002 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,9 @@ This project is currently in development! It will be announced when there is a ( GOOGLE_ID= (use google+ api) GOOGLE_SECRET= (use google+ api) MAILGUN_KEY= + EXAMPLE_USERNAME= + EXAMPLE_USER_EMAIL= + EXAMPLE_USER_PASSWORD= ``` If you don't care about being able to upload media files to S3 or Login with Github, you can drop in the file exactly how it is. Or, if you don't want to do that, just ask me to send you mine. Refer to [this gist](https://gist.github.com/catarak/70c9301f0fd1ac2d6b58de03f61997e3) for creating an S3 bucket for testing, or if you don't want to do that, I can add you to one of my S3 buckets. diff --git a/server/examples.js b/server/examples.js index 9b01c7f4..e5c9757e 100644 --- a/server/examples.js +++ b/server/examples.js @@ -135,7 +135,9 @@ function createProjectsInP5user(projectsInAllCategories) { }; rp(options).then((res) => { - User.findOne({ username: 'p5' }, (err, user) => { + const assets = JSON.parse(res); + + User.findOne({ username: process.env.EXAMPLE_USERNAME }, (err, user) => { if (err) throw err; eachSeries(projectsInAllCategories, (projectsInOneCategory, categoryCallback) => { @@ -287,15 +289,15 @@ function createProjectsInP5user(projectsInAllCategories) { } function getp5User() { - User.findOne({ username: 'p5' }, (err, user) => { + User.findOne({ username: process.env.EXAMPLE_USERNAME }, (err, user) => { if (err) throw err; let p5User = user; if (!p5User) { p5User = new User({ - username: 'p5', - email: 'p5-examples@gmail.com', - password: 'test' + username: process.env.EXAMPLE_USERNAME, + email: process.env.EXAMPLE_USER_EMAIL, + password: process.env.EXAMPLE_USER_PASSWORD }); p5User.save((saveErr) => { if (saveErr) throw saveErr;