Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
eb64c37
Fixed validation for new and improved hacker object
RohitGarudadri Nov 29, 2019
795832d
minor changes to validation schema
RohitGarudadri Nov 30, 2019
8391fba
Changed parsing of hacker and validation of application
RohitGarudadri Nov 30, 2019
2cf5f06
Fixed all tests
RohitGarudadri Dec 1, 2019
28e4dbd
Don't worry about this for now
RohitGarudadri Dec 1, 2019
759ef59
Merge branch 'develop' into feature/124-update-application-page
RohitGarudadri Dec 4, 2019
8bd4545
Fixing tests
RohitGarudadri Dec 4, 2019
4b5e06e
Who knows what is going on with this test now?
RohitGarudadri Dec 6, 2019
c169369
Ignore this
RohitGarudadri Dec 6, 2019
a78cbd9
Merge branch 'develop' into feature/124-update-application-page
RohitGarudadri Dec 6, 2019
770c7b8
Spacing fixed
RohitGarudadri Dec 6, 2019
0a849c6
Ignore
RohitGarudadri Dec 6, 2019
a3f06b5
Ignore
RohitGarudadri Dec 6, 2019
f164708
Ignore
RohitGarudadri Dec 6, 2019
009e024
Ignore
RohitGarudadri Dec 6, 2019
ee5b24d
All tests finally working, replaced undefined with null as well in ha…
RohitGarudadri Dec 6, 2019
70efd5f
Removed console.log statements
RohitGarudadri Dec 6, 2019
90acd4a
Final commit, all tests passed locally
RohitGarudadri Dec 6, 2019
3bb8c28
Fixing tests again and updating application and account models
RohitGarudadri Dec 8, 2019
bb1e727
Merge branch 'develop' of github.com:hackmcgill/hackerAPI into featur…
RohitGarudadri Dec 8, 2019
ce49ad1
Fixing more tests
RohitGarudadri Dec 8, 2019
a6e7100
Fixed tests and changed account and hacker models appropriately. Also…
RohitGarudadri Dec 8, 2019
67271cc
Added lodash module
RohitGarudadri Dec 8, 2019
d1234ce
Added lodash module
RohitGarudadri Dec 8, 2019
768381c
Added nvm
RohitGarudadri Dec 8, 2019
40b1404
Removed dependence on lodash
RohitGarudadri Dec 8, 2019
3d1814b
Removed dependence on lodash
RohitGarudadri Dec 8, 2019
6a06d33
Merge branch 'develop' into feature/124-update-application-page
RohitGarudadri Dec 11, 2019
8797e01
Merge branch 'develop' into HEAD
RohitGarudadri Dec 11, 2019
8cfbb65
Merge branch 'test' into feature/124-update-application-page
RohitGarudadri Dec 11, 2019
1cd3d7b
Changed application to have travel take an integer
RohitGarudadri Dec 11, 2019
b42fe56
Fixed hacker validator based on hacker model
RohitGarudadri Dec 11, 2019
42ddd3e
Fixed getStats
RohitGarudadri Dec 11, 2019
08734aa
removed redundancies
RohitGarudadri Dec 11, 2019
ea01f5a
Merge branch 'develop' into feature/124-update-application-page
RohitGarudadri Dec 11, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controllers/account.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function showAccount(req, res) {

/**
* @function addUser
* @param {{body: {accountDetails: {_id: ObjectId, firstName: string, lastName: string, email: string, password: string, dietaryRestrictions: string, shirtSize: string}}}} req
* @param {{body: {accountDetails: {_id: ObjectId, firstName: string, lastName: string, email: string, password: string}}}} req
* @param {*} res
* @return {JSON} Success or error status
* @description Adds a user from information in req.body.accountDetails
Expand Down
2 changes: 1 addition & 1 deletion controllers/hacker.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function showHacker(req, res) {

/**
* @function createdHacker
* @param {{body: {hacker: {_id: ObjectId, accountId: ObjectId, school: string, gender: string, needsBus: boolean, application: {Object}}}}} req
* @param {{body: {hacker: {_id: ObjectId, accountId: ObjectId, status: string, application: {Object}}}}} req
* @param {*} res
* @return {JSON} Success status
* @description returns success message
Expand Down
16 changes: 8 additions & 8 deletions docs/api/api_data.json

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions docs/api/vendor/jquery.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -1448,12 +1448,9 @@
i > 1 && sa(m),
i > 1 &&
qa(
a
.slice(0, i - 1)
.concat({
value:
" " === a[i - 2].type ? "*" : ""
})
a.slice(0, i - 1).concat({
value: " " === a[i - 2].type ? "*" : ""
})
).replace(Q, "$1"),
c,
e > i && wa(a.slice(i, e)),
Expand Down
6 changes: 4 additions & 2 deletions middlewares/account.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ function parsePatch(req, res, next) {

/**
* @function parseAccount
* @param {{body: {firstName: string, lastName: string, email: string, password: string, dietaryRestrictions: string, shirtSize: string}}} req
* @param {{body: {firstName: string, lastName: string, email: string, password: string}}} req
* @param {*} res
* @param {(err?)=>void} next
* @return {void}
* @description
* Moves firstName, lastName, email, password, dietaryRestrictions, shirtSize from req.body to req.body.accountDetails.
* Moves firstName, lastName, email, password from req.body to req.body.accountDetails.
* Hashes the password.
* Adds _id to accountDetails.
*/
Expand All @@ -49,6 +49,7 @@ function parseAccount(req, res, next) {
firstName: req.body.firstName,
lastName: req.body.lastName,
pronoun: req.body.pronoun,
gender: req.body.gender,
email: req.body.email,
password: Services.Account.hashPassword(req.body.password),
dietaryRestrictions: req.body.dietaryRestrictions,
Expand All @@ -60,6 +61,7 @@ function parseAccount(req, res, next) {
delete req.body.firstName;
delete req.body.lastName;
delete req.body.pronoun;
delete req.body.gender;
delete req.body.email;
delete req.body.password;
delete req.body.dietaryRestrictions;
Expand Down
6 changes: 3 additions & 3 deletions middlewares/auth.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ async function changePassword(req, res, next) {
req.body.oldPassword
);
// user's old password is correct
if (acc) {
if (!!acc) {
req.body.account = await Services.Account.updatePassword(
req.user.id,
req.body.newPassword
Expand Down Expand Up @@ -332,7 +332,7 @@ function parseResetToken(req, res, next) {
* @param {(err?)=>void} next
*/
function parseAccountConfirmationToken(req, res, next) {
if (req.body.token) {
if (!!req.body.token) {
jwt.verify(req.body.token, process.env.JWT_CONFIRM_ACC_SECRET, function(
err,
decoded
Expand Down Expand Up @@ -432,7 +432,7 @@ async function validateConfirmationToken(req, res, next) {
* @param {*} next
*/
async function validateConfirmationTokenWithoutAccount(req, res, next) {
if (req.body.decodedToken) {
if (!!req.body.decodedToken) {
const confirmationObj = await Services.AccountConfirmation.findById(
req.body.decodedToken.accountConfirmationId
);
Expand Down
40 changes: 10 additions & 30 deletions middlewares/hacker.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,25 @@ function parsePatch(req, res, next) {

/**
* @function parseHacker
* @param {{body: {accountId: ObjectId, school: string, degree: string, gender: string, needsBus: string, application: Object, authorization: string}}} req
* @param {{body: {accountId: ObjectId, application: Object, authorization: string}}} req
* @param {*} res
* @param {(err?)=>void} next
* @return {void}
* @description
* Moves accountId, school, degree, gender, needsBus, application from req.body to req.body.hackerDetails.
* Moves accountId, application from req.body to req.body.hackerDetails.
* Adds _id to hackerDetails.
*/
function parseHacker(req, res, next) {
const hackerDetails = {
_id: mongoose.Types.ObjectId(),
accountId: req.body.accountId,
school: req.body.school,
degree: req.body.degree,
gender: req.body.gender,
needsBus: req.body.needsBus,
application: req.body.application,

ethnicity: req.body.ethnicity,
major: req.body.major,
graduationYear: req.body.graduationYear,
codeOfConduct: req.body.codeOfConduct,

teamId: req.body.teamId
};
req.body.token = req.body.authorization;

delete req.body.accountId;
delete req.body.school;
delete req.body.degree;
delete req.body.gender;
delete req.body.needsBus;
delete req.body.application;
delete req.body.authorization;
delete req.body.ethnicity;
delete req.body.major;
delete req.body.graduationYear;
delete req.body.codeOfConduct;
delete req.body.teamId;

req.body.hackerDetails = hackerDetails;
Expand Down Expand Up @@ -280,7 +261,7 @@ async function uploadResume(req, res, next) {
req.body.gcfilename = gcfilename;
await Services.Hacker.updateOne(req.hacker.id, {
$set: {
"application.portfolioURL.resume": gcfilename
"application.general.URL.resume": gcfilename
}
});
return next();
Expand All @@ -297,11 +278,12 @@ async function downloadResume(req, res, next) {
if (
hacker &&
hacker.application &&
hacker.application.portfolioURL &&
hacker.application.portfolioURL.resume
hacker.application.general &&
hacker.application.general.URL &&
hacker.application.general.URL.resume
) {
req.body.resume = await Services.Storage.download(
hacker.application.portfolioURL.resume
hacker.application.general.URL.resume
);
} else {
return next({
Expand Down Expand Up @@ -480,7 +462,7 @@ function checkStatus(statuses) {
return Middleware.Util.asyncMiddleware(async (req, res, next) => {
let hacker = await Services.Hacker.findById(req.params.id);

if (hacker) {
if (!!hacker) {
const status = hacker.status;
// makes sure the hacker's status is in the accepted statuses list
if (statuses.indexOf(status) === -1) {
Expand Down Expand Up @@ -578,10 +560,8 @@ async function createHacker(req, res, next) {
}
});
}

const hacker = await Services.Hacker.createHacker(hackerDetails);

if (hacker) {
if (!!hacker) {
req.body.hacker = hacker;
return next();
} else {
Expand Down Expand Up @@ -636,7 +616,7 @@ async function findSelf(req, res, next) {

const hacker = await Services.Hacker.findByAccountId(req.user.id);

if (hacker) {
if (!!hacker) {
req.body.hacker = hacker;
return next();
} else {
Expand Down
2 changes: 2 additions & 0 deletions middlewares/validators/account.validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
VALIDATOR.stringValidator("body", "firstName", false),
VALIDATOR.stringValidator("body", "lastName", false),
VALIDATOR.stringValidator("body", "pronoun", false),
VALIDATOR.stringValidator("body", "gender", false),
VALIDATOR.regexValidator("body", "email", false, Constants.EMAIL_REGEX),
VALIDATOR.alphaArrayValidator("body", "dietaryRestrictions", false),
VALIDATOR.stringValidator("body", "gender", false),
Expand All @@ -24,6 +25,7 @@ module.exports = {
VALIDATOR.stringValidator("body", "firstName", true),
VALIDATOR.stringValidator("body", "lastName", true),
VALIDATOR.stringValidator("body", "pronoun", true),
VALIDATOR.stringValidator("body", "gender", true),
VALIDATOR.regexValidator("body", "email", true, Constants.EMAIL_REGEX),
VALIDATOR.alphaArrayValidator("body", "dietaryRestrictions", true),
VALIDATOR.stringValidator("body", "gender", true),
Expand Down
Loading