Skip to content

Commit eb3df1c

Browse files
brarsanmolmeldunn
andauthored
feat(hacker.js,hacker.middleware.js): add ability for discord verification. (#795)
* feat(hacker.js,hacker.middleware.js): add ability for discord verification.. * fix(hacker.js): typo in middleware function call. * add postDiscord role/route * Fix hacker discord route Co-authored-by: meldunn <dmelissa216@gmail.com>
1 parent 069cb7d commit eb3df1c

File tree

6 files changed

+40
-4
lines changed

6 files changed

+40
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,4 @@ assets/.DS_Store
6868

6969
#secrets
7070
secret.yaml
71+
package-lock.json

constants/role.constant.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const hackerRole = {
3737
Constants.Routes.hackerRoutes.patchSelfById,
3838
Constants.Routes.hackerRoutes.patchSelfConfirmationById,
3939
Constants.Routes.hackerRoutes.getSelf,
40+
Constants.Routes.hackerRoutes.postDiscord,
4041

4142
Constants.Routes.travelRoutes.getSelf,
4243
Constants.Routes.travelRoutes.getSelfById,

constants/routes.constant.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* ===***===***===***===***===***===***===***===***===
77
*
88
* If you are adding a route to this list, update this number
9-
* next avaiable createFromTime value: 166
9+
* next avaiable createFromTime value: 168
1010
*
1111
* If you are deleting a route from this list, please add the ID to the list of 'reserved' IDs,
1212
* so that we don't accidentally assign someone to a given ID.
@@ -203,6 +203,12 @@ const hackerRoutes = {
203203
uri: "/api/hacker/email/dayOf/" + Constants.ROLE_CATEGORIES.SELF,
204204
_id: mongoose.Types.ObjectId.createFromTime(134)
205205
}
206+
// },
207+
// postDiscord: {
208+
// requestType: Constants.REQUEST_TYPES.POST,
209+
// uri: "/api/hacker/discord",
210+
// _id: mongoose.Types.ObjectId.createFromTime(167)
211+
// }
206212
};
207213

208214
const travelRoutes = {
@@ -363,6 +369,11 @@ const staffRoutes = {
363369
requestType: Constants.REQUEST_TYPES.GET,
364370
uri: "/api/account/invite",
365371
_id: mongoose.Types.ObjectId.createFromTime(162)
372+
},
373+
postDiscord: {
374+
requestType: Constants.REQUEST_TYPES.POST,
375+
uri: "/api/hacker/discord",
376+
_id: mongoose.Types.ObjectId.createFromTime(167)
366377
}
367378
};
368379

middlewares/hacker.middleware.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,11 @@ async function getStats(req, res, next) {
874874
next();
875875
}
876876

877+
function addIdToCheckStatus(req, res, next) {
878+
req.params.id = req.body.hacker.id;
879+
return next();
880+
}
881+
877882
module.exports = {
878883
parsePatch: parsePatch,
879884
parseHacker: parseHacker,
@@ -929,5 +934,6 @@ module.exports = {
929934
findByEmail: Middleware.Util.asyncMiddleware(findByEmail),
930935
obtainEmailByHackerId: Middleware.Util.asyncMiddleware(
931936
obtainEmailByHackerId
932-
)
937+
),
938+
addIdToCheckStatus: addIdToCheckStatus
933939
};

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

routes/api/hacker.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,23 @@ module.exports = {
905905
Controllers.Hacker.sentDayOfEmail
906906
);
907907

908+
hackerRouter.route("/discord").post(
909+
Middleware.Auth.ensureAuthenticated(),
910+
Middleware.Auth.ensureAuthorized(),
911+
912+
// Middleware.parseBody.middleware,
913+
Middleware.Hacker.findByEmail,
914+
Middleware.Hacker.addIdToCheckStatus,
915+
Middleware.Hacker.checkStatus([
916+
CONSTANTS.HACKER_STATUS_ACCEPTED,
917+
CONSTANTS.HACKER_STATUS_CONFIRMED
918+
]),
919+
Middleware.Hacker.parseCheckIn,
920+
Middleware.Hacker.updateHacker,
921+
Middleware.Hacker.sendStatusUpdateEmail,
922+
Controllers.Hacker.updatedHacker
923+
);
924+
908925
apiRouter.use("/hacker", hackerRouter);
909926
}
910927
};

0 commit comments

Comments
 (0)