biz-slide-core 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- package/middleware/authentication.js +11 -6
- package/package.json +1 -1
@@ -104,10 +104,11 @@ var authorize = function (roles) {
|
|
104
104
|
exports.authorize = authorize;
|
105
105
|
var authorizeWithSlideApp = function () {
|
106
106
|
return function (req, res, next) {
|
107
|
+
var _a;
|
107
108
|
return __awaiter(this, void 0, void 0, function () {
|
108
|
-
var token;
|
109
|
-
return __generator(this, function (
|
110
|
-
switch (
|
109
|
+
var token, userId;
|
110
|
+
return __generator(this, function (_b) {
|
111
|
+
switch (_b.label) {
|
111
112
|
case 0:
|
112
113
|
if (!req.headers.authorization) {
|
113
114
|
return [2 /*return*/, res.status(401).json({ message: 'Unauthorized' })];
|
@@ -115,15 +116,19 @@ var authorizeWithSlideApp = function () {
|
|
115
116
|
if (!req.headers.authorization) return [3 /*break*/, 2];
|
116
117
|
return [4 /*yield*/, (0, utilities_1.verifyUid)(req.headers.authorization)];
|
117
118
|
case 1:
|
118
|
-
token =
|
119
|
+
token = _b.sent();
|
119
120
|
if (!token) {
|
120
121
|
return [2 /*return*/, res.status(401).json({ message: 'Session Expired' })];
|
121
122
|
}
|
123
|
+
userId = (token === null || token === void 0 ? void 0 : token.customer_id) || ((_a = token === null || token === void 0 ? void 0 : token.value) === null || _a === void 0 ? void 0 : _a.email);
|
124
|
+
if (!userId) {
|
125
|
+
return [2 /*return*/, res.status(401).json({ message: 'userId not found' })];
|
126
|
+
}
|
122
127
|
req.user = {
|
123
|
-
userId:
|
128
|
+
userId: userId
|
124
129
|
};
|
125
130
|
next();
|
126
|
-
|
131
|
+
_b.label = 2;
|
127
132
|
case 2: return [2 /*return*/];
|
128
133
|
}
|
129
134
|
});
|