Skip to content

Commit 085dc9e

Browse files
authored
Small rework of verify hijack (#1707)
* Too many nested if/else's makes it highly unreadable between OAuth and OpenID i.e. easier commit history searching. Been thinking about doing this since removal commit... doing it. * Probable location to add `aToken` to which is actually `aAccessToken` in dep README's. Possible location could be `aReq.session.accessToken` Applies to #1705 Post #889 #564 Auto-merge
1 parent 4badd2e commit 085dc9e

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

controllers/auth.js

+17-13
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,25 @@ exports.callback = function (aReq, aRes, aNext) {
219219
// Hijack the private verify method so we can mess stuff up freely
220220
// We use this library for things it was never intended to do
221221
if (openIdStrategies[strategy]) {
222-
if (strategy === 'steam') {
223-
strategyInstance._verify = function (aIgnore, aId, aDone) {
224-
verifyPassport(aId, strategy, username, aReq.session.user, aDone);
225-
};
226-
} else {
227-
strategyInstance._verify = function (aId, aDone) {
228-
verifyPassport(aId, strategy, username, aReq.session.user, aDone);
229-
};
222+
switch(strategy) {
223+
case 'steam':
224+
strategyInstance._verify = function (aIgnore, aId, aDone) {
225+
verifyPassport(aId, strategy, username, aReq.session.user, aDone);
226+
};
227+
break;
228+
default:
229+
strategyInstance._verify = function (aId, aDone) {
230+
verifyPassport(aId, strategy, username, aReq.session.user, aDone);
231+
};
230232
}
231233
} else {
232-
strategyInstance._verify =
233-
function (aToken, aRefreshOrSecretToken, aProfile, aDone) {
234-
aReq.session.profile = aProfile;
235-
verifyPassport(aProfile.id, strategy, username, aReq.session.user, aDone);
236-
};
234+
switch(strategy) {
235+
default:
236+
strategyInstance._verify = function (aToken, aRefreshOrSecretToken, aProfile, aDone) {
237+
aReq.session.profile = aProfile;
238+
verifyPassport(aProfile.id, strategy, username, aReq.session.user, aDone);
239+
};
240+
}
237241
}
238242

239243
// This callback will happen after the verify routine

0 commit comments

Comments
 (0)