Skip to content

Commit 3815f2d

Browse files
authored
Merge pull request #160 from hackmcgill/feature/105
Feature/105
2 parents 4cdcc09 + cc689ba commit 3815f2d

25 files changed

Lines changed: 947 additions & 130 deletions

constants/error.constant.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const SPONSOR_ID_409_MESSAGE = "Conflict with sponsor accountId link";
1111
const VOLUNTEER_ID_409_MESSAGE = "Conflict with volunteer accountId link";
1212
const HACKER_ID_409_MESSAGE = "Conflict with hacker accountId link";
1313
const TEAM_MEMBER_409_MESSAGE = "Conflict with team member being in another team";
14+
const HACKER_STATUS_409_MESSAGE = "Conflict with hacker status";
1415

1516
const TEAM_MEMBER_422_MESSAGE = "Duplicate team member in input";
1617
const VALIDATION_422_MESSAGE = "Validation failed";
@@ -59,4 +60,5 @@ module.exports = {
5960
GENERIC_500_MESSAGE: GENERIC_500_MESSAGE,
6061
ACCOUNT_DUPLICATE_422_MESSAGE: ACCOUNT_DUPLICATE_422_MESSAGE,
6162
LOGIN_500_MESSAGE: LOGIN_500_MESSAGE,
63+
HACKER_STATUS_409_MESSAGE: HACKER_STATUS_409_MESSAGE,
6264
};

constants/role.constant.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const hackerRole = {
3636
Constants.Routes.hackerRoutes.getSelfById,
3737
Constants.Routes.hackerRoutes.getSelfResumeById,
3838
Constants.Routes.hackerRoutes.patchSelfById,
39+
Constants.Routes.hackerRoutes.patchSelfConfirmationById
3940
]
4041
};
4142

@@ -44,6 +45,9 @@ const volunteerRole = {
4445
"name": Constants.General.VOLUNTEER,
4546
"routes": [
4647
Constants.Routes.volunteerRoutes.post,
48+
49+
Constants.Routes.hackerRoutes.patchAnyCheckInById,
50+
Constants.Routes.hackerRoutes.patchSelfCheckInById,
4751
]
4852
};
4953

constants/routes.constant.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,19 @@ const hackerRoutes = {
9999
"patchSelfStatusById": {
100100
requestType: Constants.REQUEST_TYPES.PATCH,
101101
uri: "/api/hacker/status/" + Constants.ROLE_CATEGORIES.SELF,
102-
}
102+
},
103+
"patchSelfCheckInById": {
104+
requestType: Constants.REQUEST_TYPES.PATCH,
105+
uri: "/api/hacker/checkin/" + Constants.ROLE_CATEGORIES.SELF,
106+
},
107+
"patchAnyCheckInById": {
108+
requestType: Constants.REQUEST_TYPES.PATCH,
109+
uri: "/api/hacker/checkin/" + Constants.ROLE_CATEGORIES.ALL,
110+
},
111+
"patchSelfConfirmationById": {
112+
requestType: Constants.REQUEST_TYPES.PATCH,
113+
uri: "/api/hacker/confirmation/" + Constants.ROLE_CATEGORIES.SELF,
114+
},
103115
};
104116

105117
const sponsorRoutes = {

controllers/account.controller.js

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -67,49 +67,36 @@ async function getUserById(req, res) {
6767
* @description Adds a user from information in req.body.accountDetails
6868
*/
6969
async function addUser(req, res) {
70-
const accountDetails = req.body.accountDetails;
71-
delete accountDetails.password;
70+
const acc = req.body.account;
7271
return res.status(200).json({
7372
message: "Account creation successful",
74-
data: accountDetails
73+
data: acc.toStrippedJSON()
7574
});
7675
}
7776

7877

7978
/**
80-
* @async
81-
* @function updateAccount
82-
* @param {{params: {id: string}, body: {Object}}} req
79+
* @function updatedAccount
80+
* @param {{body: {Object}}} req
8381
* @param {*} res
8482
* @return {JSON} Success or error status
8583
* @description
86-
* Change a user's account information based on the account's mongoID.
84+
* Returns a 200 status for an updated account.
8785
* The new account information is located in req.body.
8886
* The id is moved to req.body.id from req.params.id by validation.
8987
*/
90-
async function updateAccount(req, res) {
91-
const id = req.params.id;
92-
93-
const success = await Services.Account.changeOneAccount(id, req.body);
94-
95-
if (success) {
96-
return res.status(200).json({
97-
message: "Changed account information",
98-
data: req.body
99-
});
100-
} else {
101-
return res.status(500).json({
102-
message: Constants.Error.ACCOUNT_UPDATE_500_MESSAGE,
103-
data: {}
104-
});
105-
}
88+
function updatedAccount(req, res) {
89+
return res.status(200).json({
90+
message: "Changed account information",
91+
data: req.body
92+
});
10693
}
10794

108-
function invitedAccount(req, res){
95+
function invitedAccount(req, res) {
10996
return res.status(200).json({
11097
message: "Successfully invited user",
11198
data: {}
112-
})
99+
});
113100
}
114101

115102

@@ -119,7 +106,6 @@ module.exports = {
119106

120107
// assumes all information in req.body
121108
addUser: Util.asyncMiddleware(addUser),
122-
123-
updateAccount: Util.asyncMiddleware(updateAccount),
109+
updatedAccount: updatedAccount,
124110
invitedAccount: invitedAccount
125111
};

controllers/auth.controller.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,40 @@ module.exports = {
1414
data: {}
1515
});
1616
},
17-
sentResetEmail: function(req, res) {
17+
sentResetEmail: function (req, res) {
1818
return res.status(200).json({
1919
message: "Sent reset email",
2020
data: {}
2121
});
2222
},
23-
resetPassword: function(req, res) {
23+
resetPassword: function (req, res) {
2424
return res.status(200).json({
2525
message: "Successfully reset password",
2626
data: {}
2727
});
2828
},
29-
confirmAccount: function(req, res) {
29+
confirmAccount: function (req, res) {
3030
return res.status(200).json({
3131
message: "Successfully confirmed account",
3232
data: {}
33-
})
33+
});
3434
},
35-
retrieveRoleBindings: function(req, res) {
35+
retrieveRoleBindings: function (req, res) {
3636
return res.status(200).json({
3737
message: "Successfully retrieved role bindings",
3838
data: req.roleBindings.toJSON()
39-
})
39+
});
4040
},
41-
sentConfirmationEmail: function(req, res){
41+
sentConfirmationEmail: function (req, res) {
4242
return res.status(200).json({
4343
message: "Successfully resent account email",
4444
data: {}
4545
})
4646
},
47-
retrievedRoles: function(req, res) {
47+
retrievedRoles: function (req, res) {
4848
return res.status(200).json({
4949
message: "Successfully retrieved all roles",
5050
data: req.roles
5151
})
5252
}
53-
};
53+
};

controllers/hacker.controller.js

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,33 +33,20 @@ async function findById(req, res) {
3333
}
3434

3535
/**
36-
* @async
37-
* @function createHacker
38-
* @param {{body: {hackerDetails: {_id: ObjectId, accountId: ObjectId, school: string, gender: string, needsBus: boolean, application: {Object}}}}} req
36+
* @function createdHacker
37+
* @param {{body: {hacker: {_id: ObjectId, accountId: ObjectId, school: string, gender: string, needsBus: boolean, application: {Object}}}}} req
3938
* @param {*} res
40-
* @return {JSON} Success or error status
41-
* @description create a hacker from information in req.body.hackerDetails
39+
* @return {JSON} Success status
40+
* @description returns success message
4241
*/
43-
async function createHacker(req, res) {
44-
const hackerDetails = req.body.hackerDetails;
45-
const success = await Services.Hacker.createHacker(hackerDetails);
46-
hackerDetails.id = hackerDetails._id;
47-
delete hackerDetails._id;
48-
if (success) {
49-
return res.status(200).json({
50-
message: "Hacker creation successful",
51-
data: hackerDetails
52-
});
53-
} else {
54-
return res.status(500).json({
55-
message: Constants.Error.HACKER_CREATE_500_MESSAGE,
56-
data: {}
57-
});
58-
}
42+
async function createdHacker(req, res) {
43+
return res.status(200).json({
44+
message: "Hacker creation successful",
45+
data: req.body.hacker.toJSON()
46+
});
5947
}
6048

6149
/**
62-
* @async
6350
* @function updateHacker
6451
* @param {{params: {id: ObjectId}, body: {Object}}} req
6552
* @param {*} res
@@ -70,7 +57,7 @@ async function createHacker(req, res) {
7057
* Returns a 200 status for an updated hacker.
7158
* The new information is located in req.body.
7259
*/
73-
async function updatedHacker(req, res) {
60+
function updatedHacker(req, res) {
7461
return res.status(200).json({
7562
message: "Changed hacker information",
7663
data: req.body
@@ -99,7 +86,7 @@ function downloadedResume(req, res) {
9986
module.exports = {
10087
updatedHacker: updatedHacker,
10188
findById: Util.asyncMiddleware(findById),
102-
createHacker: Util.asyncMiddleware(createHacker),
89+
createdHacker: createdHacker,
10390
uploadedResume: uploadedResume,
10491
downloadedResume: downloadedResume
10592
};

0 commit comments

Comments
 (0)