Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit cbc7e9e

Browse files
committed
I-142557 - support new auth0 formats
1 parent bd4226a commit cbc7e9e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

initializers/middleware.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,13 @@ exports.middleware = function (api, next) {
107107
return;
108108
}
109109
var split = decoded.sub.split("|");
110-
socialUserId = (split.pop() || "").trim();
111-
socialProvider = (split.pop() || "").trim();
110+
try {
111+
socialUserId = (split[split.length-1] || "").trim();
112+
socialProvider = (split[0] || "").trim();
113+
} catch (ignored) {
114+
cb(new IllegalArgumentError('Malformed Auth header. Could not parse token.sub!'));
115+
return;
116+
}
112117
if (!_.isDefined(socialUserId) || socialUserId.length === 0) {
113118
cb(new IllegalArgumentError('Malformed Auth header. No userId in token.sub!'));
114119
return;

0 commit comments

Comments
 (0)