Skip to content

Commit

Permalink
Lint execution 💪
Browse files Browse the repository at this point in the history
  • Loading branch information
UlisesGascon committed Mar 18, 2020
1 parent 2a79334 commit f211301
Show file tree
Hide file tree
Showing 47 changed files with 836 additions and 767 deletions.
4 changes: 2 additions & 2 deletions apps/server-render/app/data/allocations-dao.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const UserDAO = require("./user-dao").UserDAO;

/* The AllocationsDAO must be constructed with a connected database object */
const AllocationsDAO = function(db){
const AllocationsDAO = function(db) {

"use strict";

Expand Down Expand Up @@ -90,7 +90,7 @@ const AllocationsDAO = function(db){
let doneCounter = 0;
const userAllocations = [];

allocations.forEach( alloc => {
allocations.forEach(alloc => {
userDAO.getUserById(alloc.userId, (err, user) => {
if (err) return callback(err, null);

Expand Down
4 changes: 3 additions & 1 deletion apps/server-render/app/data/benefits-dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ function BenefitsDAO(db) {
};
}

module.exports = { BenefitsDAO };
module.exports = {
BenefitsDAO
};
6 changes: 4 additions & 2 deletions apps/server-render/app/data/contributions-dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function ContributionsDAO(db) {
};

contributionsDB.update({
userId
userId
},
contributions, {
upsert: true
Expand Down Expand Up @@ -83,4 +83,6 @@ function ContributionsDAO(db) {
};
}

module.exports = { ContributionsDAO };
module.exports = {
ContributionsDAO
};
4 changes: 3 additions & 1 deletion apps/server-render/app/data/memos-dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ function MemosDAO(db) {

}

module.exports = { MemosDAO };
module.exports = {
MemosDAO
};
4 changes: 3 additions & 1 deletion apps/server-render/app/data/profile-dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,6 @@ function ProfileDAO(db) {
};
}

module.exports = { ProfileDAO };
module.exports = {
ProfileDAO
};
4 changes: 3 additions & 1 deletion apps/server-render/app/data/research-dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ function ResearchDAO(db) {
}
}

module.exports = { ResearchDAO };
module.exports = {
ResearchDAO
};
6 changes: 4 additions & 2 deletions apps/server-render/app/data/user-dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ function UserDAO(db) {
}, {
new: true
},
(err, data) => err ? callback(err, null) : callback(null, data.value.seq));
(err, data) => err ? callback(err, null) : callback(null, data.value.seq));
};
}

module.exports = { UserDAO };
module.exports = {
UserDAO
};
15 changes: 11 additions & 4 deletions apps/server-render/app/routes/allocations.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const AllocationsDAO = require("../data/allocations-dao").AllocationsDAO;

function AllocationsHandler (db) {
function AllocationsHandler(db) {
"use strict";

const allocationsDAO = new AllocationsDAO(db);
Expand All @@ -10,12 +10,19 @@ function AllocationsHandler (db) {
// Fix for A4 Insecure DOR - take user id from session instead of from URL param
const { userId } = req.session;
*/
const {userId} = req.params;
const { threshold } = req.query
const {
userId
} = req.params;
const {
threshold
} = req.query

allocationsDAO.getByUserIdAndThreshold(userId, threshold, (err, allocations) => {
if (err) return next(err);
return res.render("allocations", { userId, allocations });
return res.render("allocations", {
userId,
allocations
});
});
};
}
Expand Down
11 changes: 8 additions & 3 deletions apps/server-render/app/routes/benefits.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const { BenefitsDAO } = require("../data/benefits-dao");
const {
BenefitsDAO
} = require("../data/benefits-dao");

function BenefitsHandler (db) {
function BenefitsHandler(db) {
"use strict";

const benefitsDAO = new BenefitsDAO(db);
Expand All @@ -21,7 +23,10 @@ function BenefitsHandler (db) {
};

this.updateBenefits = (req, res, next) => {
const { userId, benefitStartDate } = req.body;
const {
userId,
benefitStartDate
} = req.body;

benefitsDAO.updateBenefits(userId, benefitStartDate, (error) => {

Expand Down
10 changes: 7 additions & 3 deletions apps/server-render/app/routes/contributions.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
const ContributionsDAO = require("../data/contributions-dao").ContributionsDAO;

/* The ContributionsHandler must be constructed with a connected db */
function ContributionsHandler (db) {
function ContributionsHandler(db) {
"use strict";

const contributionsDAO = new ContributionsDAO(db);

this.displayContributions = (req, res, next) => {
const { userId } = req.session;
const {
userId
} = req.session;

contributionsDAO.getByUserId(userId, (error, contrib) => {
if (error) return next(error);
Expand All @@ -31,7 +33,9 @@ function ContributionsHandler (db) {
const afterTax = parseInt(req.body.afterTax);
const roth = parseInt(req.body.roth);
*/
const { userId } = req.session;
const {
userId
} = req.session;

//validate contributions
const validations = [isNaN(preTax), isNaN(afterTax), isNaN(roth), preTax < 0, afterTax < 0, roth < 0]
Expand Down
6 changes: 4 additions & 2 deletions apps/server-render/app/routes/error.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Error handling middleware

const errorHandler = (err, req, res,next) => {
const errorHandler = (err, req, res, next) => {

"use strict";

Expand All @@ -12,4 +12,6 @@ const errorHandler = (err, req, res,next) => {
});
};

module.exports = { errorHandler };
module.exports = {
errorHandler
};
6 changes: 4 additions & 2 deletions apps/server-render/app/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ const index = (app, db) => {
app.get("/tutorial", (req, res) => {
return res.render("tutorial/a1");
});

app.get("/tutorial/:page", (req, res) => {
const { page } = req.params
const {
page
} = req.params
return res.render(`tutorial/${page}`);
});

Expand Down
6 changes: 4 additions & 2 deletions apps/server-render/app/routes/memos.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const MemosDAO = require("../data/memos-dao").MemosDAO;

function MemosHandler (db) {
function MemosHandler(db) {
"use strict";

const memosDAO = new MemosDAO(db);
Expand All @@ -15,7 +15,9 @@ function MemosHandler (db) {

this.displayMemos = (req, res, next) => {

const { userId } = req.session;
const {
userId
} = req.session;

memosDAO.getAllMemos((err, docs) => {
if (err) return next(err);
Expand Down
20 changes: 16 additions & 4 deletions apps/server-render/app/routes/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ const ProfileDAO = require("../data/profile-dao").ProfileDAO;
const ESAPI = require('node-esapi')

/* The ProfileHandler must be constructed with a connected db */
function ProfileHandler (db) {
function ProfileHandler(db) {
"use strict";

const profile = new ProfileDAO(db);

this.displayProfile = (req, res, next) => {
const { userId } = req.session;
const {
userId
} = req.session;



Expand All @@ -31,7 +33,15 @@ function ProfileHandler (db) {

this.handleProfileUpdate = (req, res, next) => {

const {firstName, lastName, ssn, dob, address, bankAcc, bankRouting} = req.body;
const {
firstName,
lastName,
ssn,
dob,
address,
bankAcc,
bankRouting
} = req.body;

// Fix for Section: ReDoS attack
// The following regexPattern that is used to validate the bankRouting number is insecure and vulnerable to
Expand All @@ -58,7 +68,9 @@ function ProfileHandler (db) {
});
}

const { userId } = req.session;
const {
userId
} = req.session;

profile.updateUser(
parseInt(userId),
Expand Down
20 changes: 11 additions & 9 deletions apps/server-render/app/routes/research.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
const ResearchDAO = require("../data/research-dao").ResearchDAO;
const needle = require('needle');

function ResearchHandler (db) {
function ResearchHandler(db) {
"use strict";

const researchDAO = new ResearchDAO(db);

this.displayResearch = (req, res) => {

if (req.query.symbol) {
const url = req.query.url+req.query.symbol;
const url = req.query.url + req.query.symbol;
return needle.get(url, (error, newResponse) => {
if (!error && newResponse.statusCode == 200)
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('<h1>The following is the stock information you requested.</h1>\n\n');
res.write('\n\n');
res.write(newResponse.body);
return res.end();
res.writeHead(200, {
'Content-Type': 'text/html'
});
res.write('<h1>The following is the stock information you requested.</h1>\n\n');
res.write('\n\n');
res.write(newResponse.body);
return res.end();
});
}

return res.render("research");
};

Expand Down
22 changes: 16 additions & 6 deletions apps/server-render/app/routes/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const UserDAO = require("../data/user-dao").UserDAO;
const AllocationsDAO = require("../data/allocations-dao").AllocationsDAO;

/* The SessionHandler must be constructed with a connected db */
function SessionHandler (db) {
function SessionHandler(db) {
"use strict";

const userDAO = new UserDAO(db);
Expand All @@ -22,16 +22,16 @@ function SessionHandler (db) {
this.isAdminUserMiddleware = (req, res, next) => {
if (req.session.userId) {
return userDAO.getUserById(req.session.userId, (err, user) => user && user.isAdmin ? next() : res.redirect("/login"));
}
}
console.log("redirecting to login");
return res.redirect("/login");

};

this.isLoggedInMiddleware = (req, res, next) => {
if (req.session.userId) {
return next();
}
}
console.log("redirecting to login");
return res.redirect("/login");
};
Expand All @@ -45,7 +45,10 @@ function SessionHandler (db) {
};

this.handleLoginRequest = (req, res, next) => {
const { userName, password } = req.body
const {
userName,
password
} = req.body
userDAO.validateLogin(userName, password, (err, user) => {
const errorMessage = "Invalid username and/or password";
const invalidUserNameErrorMessage = "Invalid username";
Expand Down Expand Up @@ -173,7 +176,14 @@ function SessionHandler (db) {

this.handleSignup = (req, res, next) => {

const { email, userName, firstName, lastName, password, verify } = req.body;
const {
email,
userName,
firstName,
lastName,
password,
verify
} = req.body;

// set these up in case we have an error case
const errors = {
Expand Down
2 changes: 1 addition & 1 deletion apps/server-render/app/views/allocations.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ <h3 class="panel-title">

</div>
</div>
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion apps/server-render/app/views/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@

</body>

</html>
</html>
10 changes: 5 additions & 5 deletions apps/server-render/app/views/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@
<span style="font-size: x-large">
<span class="fa fa-bullseye"></span>Retire<b>Easy</b>
</span>
<br/>
<br />
<span style="font-size: medium">Employee Retirement Savings Management</span>
<br/>
<br/>
<br />
<br />
</div>
<div class="panel-body">

Expand Down Expand Up @@ -158,9 +158,9 @@
document.cookie = "testcookie=1";

if (!document.cookie) return false;

document.cookie = "testcookie=; expires=" + new Date(0).toUTCString();

}

return true;
Expand Down
Loading

0 comments on commit f211301

Please sign in to comment.