Skip to content

Commit 9a2209f

Browse files
authored
Merge branch 'develop' into feature/287
2 parents 3b8532f + 85f9ca5 commit 9a2209f

File tree

19 files changed

+395
-48
lines changed

19 files changed

+395
-48
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.1
1+
1.3.0

assets/email/statusEmail/Accepted.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@
381381
Here are your next steps:
382382
<br><br>
383383
<li style="-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;color:#4D4D4D;" >Confirm your attendance on our hacker dashboard no later than
384-
(date)</li>
385-
<li style="-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;color:#4D4D4D;" >Join our FB group to mingle with other hackers coming to McHacks 6</li>
384+
Friday, January 18.</li>
385+
<li style="-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;color:#4D4D4D;" >Join our <a href="https://www.facebook.com/groups/mchacks6" style="-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;color:#F2463A;text-decoration:none;" >FB group</a> to mingle with other hackers coming to McHacks 6!</li>
386386
<br><br>
387387
We've received an overwhelming number of applicants this year for only
388388
600 spots. If you can no longer attend McHacks 6, please let us know by
@@ -443,4 +443,4 @@
443443
</center>
444444
</body>
445445

446-
</html>
446+
</html>

constants/role.constant.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const hackerRole = {
3535

3636
Constants.Routes.hackerRoutes.post,
3737
Constants.Routes.hackerRoutes.getSelfById,
38+
Constants.Routes.hackerRoutes.getSelfByEmail,
3839
Constants.Routes.hackerRoutes.getSelfResumeById,
3940
Constants.Routes.hackerRoutes.patchSelfById,
4041
Constants.Routes.hackerRoutes.patchSelfConfirmationById,

constants/routes.constant.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ const hackerRoutes = {
6868
requestType: Constants.REQUEST_TYPES.GET,
6969
uri: "/api/hacker/" + Constants.ROLE_CATEGORIES.ALL,
7070
},
71+
"getSelfByEmail": {
72+
requestType: Constants.REQUEST_TYPES.GET,
73+
uri: "/api/hacker/email/" + Constants.ROLE_CATEGORIES.SELF,
74+
},
75+
"getAnyByEmail": {
76+
requestType: Constants.REQUEST_TYPES.GET,
77+
uri: "/api/hacker/email/" + Constants.ROLE_CATEGORIES.ALL,
78+
},
7179
"getSelfResumeById": {
7280
requestType: Constants.REQUEST_TYPES.GET,
7381
uri: "/api/hacker/resume/" + Constants.ROLE_CATEGORIES.SELF,

docs/api/api_data.js

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,14 @@ define({
7171
"field": "phoneNumber",
7272
"description": "<p>the user's phone number, represented as a string.</p>"
7373
}
74-
]
74+
],
75+
"header": [{
76+
"group": "header",
77+
"type": "JWT",
78+
"optional": true,
79+
"field": "token",
80+
"description": "<p>the user's invite token.</p>"
81+
}]
7582
},
7683
"examples": [{
7784
"title": "Request-Example:",
@@ -1248,6 +1255,78 @@ define({
12481255
"url": "https://api.mchacks.ca/api/hacker/"
12491256
}]
12501257
},
1258+
{
1259+
"type": "get",
1260+
"url": "/hacker/email/:email",
1261+
"title": "get a hacker's information",
1262+
"name": "getHacker",
1263+
"group": "Hacker",
1264+
"version": "0.0.8",
1265+
"parameter": {
1266+
"fields": {
1267+
"param": [{
1268+
"group": "param",
1269+
"type": "String",
1270+
"optional": false,
1271+
"field": "email",
1272+
"description": "<p>a hacker's unique email</p>"
1273+
}]
1274+
}
1275+
},
1276+
"success": {
1277+
"fields": {
1278+
"Success 200": [{
1279+
"group": "Success 200",
1280+
"type": "String",
1281+
"optional": false,
1282+
"field": "message",
1283+
"description": "<p>Success message</p>"
1284+
},
1285+
{
1286+
"group": "Success 200",
1287+
"type": "Object",
1288+
"optional": false,
1289+
"field": "data",
1290+
"description": "<p>Hacker object</p>"
1291+
}
1292+
]
1293+
},
1294+
"examples": [{
1295+
"title": "Success-Response: ",
1296+
"content": "{\n \"message\": \"Successfully retrieved hacker information\", \n \"data\": {\n \"id\":\"5bff4d736f86be0a41badb91\",\n \"application\":{\n \"portfolioURL\":{\n \"resume\":\"resumes/1543458163426-5bff4d736f86be0a41badb91\",\n \"github\":\"https://github.com/abcd\",\n \"dropler\":\"https://dribbble.com/abcd\",\n \"personal\":\"https://www.hi.com/\",\n \"linkedIn\":\"https://linkedin.com/in/abcd\",\n \"other\":\"https://github.com/hackmcgill/hackerAPI/issues/168\"\n },\n \"jobInterest\":\"Internship\",\n \"skills\":[\"Javascript\",\"Typescript\"],\n \"comments\":\"hi!\",\n \"essay\":\"Pls accept me\"\n },\n \"status\":\"Applied\",\n \"ethnicity\":[\"White or Caucasian\",\" Asian or Pacific Islander\"],\n \"accountId\":\"5bff2a35e533b0f6562b4998\",\n \"school\":\"McPherson College\",\n \"gender\":\"Female\",\n \"needsBus\":false,\n \"major\":\"Accounting\",\n \"graduationYear\":2019,\n \"codeOfConduct\":true,\n }\n }",
1297+
"type": "object"
1298+
}]
1299+
},
1300+
"error": {
1301+
"fields": {
1302+
"Error 4xx": [{
1303+
"group": "Error 4xx",
1304+
"type": "String",
1305+
"optional": false,
1306+
"field": "message",
1307+
"description": "<p>Error message</p>"
1308+
},
1309+
{
1310+
"group": "Error 4xx",
1311+
"type": "Object",
1312+
"optional": false,
1313+
"field": "data",
1314+
"description": "<p>empty</p>"
1315+
}
1316+
]
1317+
},
1318+
"examples": [{
1319+
"title": "Error-Response: ",
1320+
"content": "{\"message\": \"Hacker not found\", \"data\": {}}",
1321+
"type": "object"
1322+
}]
1323+
},
1324+
"filename": "routes/api/hacker.js",
1325+
"groupTitle": "Hacker",
1326+
"sampleRequest": [{
1327+
"url": "https://api.mchacks.ca/api/hacker/email/:email"
1328+
}]
1329+
},
12511330
{
12521331
"type": "get",
12531332
"url": "/hacker/:id",
@@ -1280,7 +1359,7 @@ define({
12801359
"type": "Object",
12811360
"optional": false,
12821361
"field": "data",
1283-
"description": "<p>Sponsor object</p>"
1362+
"description": "<p>Hacker object</p>"
12841363
}
12851364
]
12861365
},

docs/api/api_data.json

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,14 @@
7070
"field": "phoneNumber",
7171
"description": "<p>the user's phone number, represented as a string.</p>"
7272
}
73-
]
73+
],
74+
"header": [{
75+
"group": "header",
76+
"type": "JWT",
77+
"optional": true,
78+
"field": "token",
79+
"description": "<p>the user's invite token.</p>"
80+
}]
7481
},
7582
"examples": [{
7683
"title": "Request-Example:",
@@ -1247,6 +1254,78 @@
12471254
"url": "https://api.mchacks.ca/api/hacker/"
12481255
}]
12491256
},
1257+
{
1258+
"type": "get",
1259+
"url": "/hacker/email/:email",
1260+
"title": "get a hacker's information",
1261+
"name": "getHacker",
1262+
"group": "Hacker",
1263+
"version": "0.0.8",
1264+
"parameter": {
1265+
"fields": {
1266+
"param": [{
1267+
"group": "param",
1268+
"type": "String",
1269+
"optional": false,
1270+
"field": "email",
1271+
"description": "<p>a hacker's unique email</p>"
1272+
}]
1273+
}
1274+
},
1275+
"success": {
1276+
"fields": {
1277+
"Success 200": [{
1278+
"group": "Success 200",
1279+
"type": "String",
1280+
"optional": false,
1281+
"field": "message",
1282+
"description": "<p>Success message</p>"
1283+
},
1284+
{
1285+
"group": "Success 200",
1286+
"type": "Object",
1287+
"optional": false,
1288+
"field": "data",
1289+
"description": "<p>Hacker object</p>"
1290+
}
1291+
]
1292+
},
1293+
"examples": [{
1294+
"title": "Success-Response: ",
1295+
"content": "{\n \"message\": \"Successfully retrieved hacker information\", \n \"data\": {\n \"id\":\"5bff4d736f86be0a41badb91\",\n \"application\":{\n \"portfolioURL\":{\n \"resume\":\"resumes/1543458163426-5bff4d736f86be0a41badb91\",\n \"github\":\"https://github.com/abcd\",\n \"dropler\":\"https://dribbble.com/abcd\",\n \"personal\":\"https://www.hi.com/\",\n \"linkedIn\":\"https://linkedin.com/in/abcd\",\n \"other\":\"https://github.com/hackmcgill/hackerAPI/issues/168\"\n },\n \"jobInterest\":\"Internship\",\n \"skills\":[\"Javascript\",\"Typescript\"],\n \"comments\":\"hi!\",\n \"essay\":\"Pls accept me\"\n },\n \"status\":\"Applied\",\n \"ethnicity\":[\"White or Caucasian\",\" Asian or Pacific Islander\"],\n \"accountId\":\"5bff2a35e533b0f6562b4998\",\n \"school\":\"McPherson College\",\n \"gender\":\"Female\",\n \"needsBus\":false,\n \"major\":\"Accounting\",\n \"graduationYear\":2019,\n \"codeOfConduct\":true,\n }\n }",
1296+
"type": "object"
1297+
}]
1298+
},
1299+
"error": {
1300+
"fields": {
1301+
"Error 4xx": [{
1302+
"group": "Error 4xx",
1303+
"type": "String",
1304+
"optional": false,
1305+
"field": "message",
1306+
"description": "<p>Error message</p>"
1307+
},
1308+
{
1309+
"group": "Error 4xx",
1310+
"type": "Object",
1311+
"optional": false,
1312+
"field": "data",
1313+
"description": "<p>empty</p>"
1314+
}
1315+
]
1316+
},
1317+
"examples": [{
1318+
"title": "Error-Response: ",
1319+
"content": "{\"message\": \"Hacker not found\", \"data\": {}}",
1320+
"type": "object"
1321+
}]
1322+
},
1323+
"filename": "routes/api/hacker.js",
1324+
"groupTitle": "Hacker",
1325+
"sampleRequest": [{
1326+
"url": "https://api.mchacks.ca/api/hacker/email/:email"
1327+
}]
1328+
},
12501329
{
12511330
"type": "get",
12521331
"url": "/hacker/:id",
@@ -1279,7 +1358,7 @@
12791358
"type": "Object",
12801359
"optional": false,
12811360
"field": "data",
1282-
"description": "<p>Sponsor object</p>"
1361+
"description": "<p>Hacker object</p>"
12831362
}
12841363
]
12851364
},

docs/api/api_project.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
define({
2-
"name": "hackerAPI",
3-
"version": "0.0.8",
4-
"description": "Documentation for the API used for mchacks",
5-
"defaultVersion": "0.0.8",
6-
"title": "hackerAPI documentation",
7-
"url": "https://api.mchacks.ca/api",
8-
"sampleUrl": "https://api.mchacks.ca/api",
9-
"apidoc": "0.3.0",
10-
"generator": {
11-
"name": "apidoc",
12-
"time": "2019-01-10T02:53:36.684Z",
13-
"url": "http://apidocjs.com",
14-
"version": "0.17.7"
15-
}
1+
define({
2+
"name": "hackerAPI",
3+
"version": "0.0.8",
4+
"description": "Documentation for the API used for mchacks",
5+
"defaultVersion": "0.0.8",
6+
"title": "hackerAPI documentation",
7+
"url": "https://api.mchacks.ca/api",
8+
"sampleUrl": "https://api.mchacks.ca/api",
9+
"apidoc": "0.3.0",
10+
"generator": {
11+
"name": "apidoc",
12+
"time": "2019-01-10T23:24:21.462Z",
13+
"url": "http://apidocjs.com",
14+
"version": "0.17.7"
15+
}
1616
});

docs/api/api_project.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
{
2-
"name": "hackerAPI",
3-
"version": "0.0.8",
4-
"description": "Documentation for the API used for mchacks",
5-
"defaultVersion": "0.0.8",
6-
"title": "hackerAPI documentation",
7-
"url": "https://api.mchacks.ca/api",
8-
"sampleUrl": "https://api.mchacks.ca/api",
9-
"apidoc": "0.3.0",
10-
"generator": {
11-
"name": "apidoc",
12-
"time": "2019-01-10T02:53:36.684Z",
13-
"url": "http://apidocjs.com",
14-
"version": "0.17.7"
15-
}
1+
{
2+
"name": "hackerAPI",
3+
"version": "0.0.8",
4+
"description": "Documentation for the API used for mchacks",
5+
"defaultVersion": "0.0.8",
6+
"title": "hackerAPI documentation",
7+
"url": "https://api.mchacks.ca/api",
8+
"sampleUrl": "https://api.mchacks.ca/api",
9+
"apidoc": "0.3.0",
10+
"generator": {
11+
"name": "apidoc",
12+
"time": "2019-01-10T23:24:21.462Z",
13+
"url": "http://apidocjs.com",
14+
"version": "0.17.7"
15+
}
1616
}

middlewares/auth.middleware.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,17 @@ function createRoleBindings(roleName = undefined) {
423423
});
424424
}
425425

426+
/**
427+
* Adds a rolebinding between the user and the role with the name stored in 'accountType'.
428+
* @param {{user: {id: ObjectId, accountType: string}}} req
429+
* @param {*} res
430+
* @param {(err?) => void} next
431+
*/
432+
async function addAccountTypeRoleBinding(req, res, next) {
433+
await Services.RoleBinding.createRoleBindingByRoleName(req.user.id, req.user.accountType);
434+
return next();
435+
}
436+
426437
/**
427438
* Middleware to retrieve all the roles in the database
428439
* @param {*} req
@@ -450,6 +461,7 @@ module.exports = {
450461
getAccountTypeFromConfirmationToken: Middleware.Util.asyncMiddleware(getAccountTypeFromConfirmationToken),
451462
validateConfirmationTokenWithoutAccount: Middleware.Util.asyncMiddleware(validateConfirmationTokenWithoutAccount),
452463
createRoleBindings: createRoleBindings,
464+
addAccountTypeRoleBinding: Middleware.Util.asyncMiddleware(addAccountTypeRoleBinding),
453465
addCreationRoleBindings: Middleware.Util.asyncMiddleware(addCreationRoleBindings),
454466
resendConfirmAccountEmail: Middleware.Util.asyncMiddleware(resendConfirmAccountEmail),
455467
retrieveRoleBindings: Middleware.Util.asyncMiddleware(retrieveRoleBindings),

middlewares/hacker.middleware.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,27 @@ async function findById(req, res, next) {
178178
next();
179179
}
180180

181+
async function findByEmail(req, res, next) {
182+
const account = await Services.Account.findByEmail(req.body.email);
183+
if (!account) {
184+
return next({
185+
status: 404,
186+
message: Constants.Error.ACCOUNT_404_MESSAGE,
187+
error: {}
188+
});
189+
}
190+
const hacker = await Services.Hacker.findByAccountId(account._id);
191+
if (!hacker) {
192+
return res.status(404).json({
193+
message: Constants.Error.HACKER_404_MESSAGE,
194+
data: {}
195+
});
196+
}
197+
198+
req.body.hacker = hacker;
199+
next();
200+
}
201+
181202
/**
182203
* Verifies that the current signed in user is linked to the hacker passed in via req.body.id
183204
* @param {{body: {id: ObjectId}}} req
@@ -512,4 +533,5 @@ module.exports = {
512533
findSelf: Middleware.Util.asyncMiddleware(findSelf),
513534
getStats: Middleware.Util.asyncMiddleware(getStats),
514535
findById: Middleware.Util.asyncMiddleware(findById),
536+
findByEmail: Middleware.Util.asyncMiddleware(findByEmail),
515537
};

0 commit comments

Comments
 (0)