biz-slide-core 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 (_a) {
110
- switch (_a.label) {
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 = _a.sent();
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: token.value.email || token.value.customer_id
128
+ userId: userId
124
129
  };
125
130
  next();
126
- _a.label = 2;
131
+ _b.label = 2;
127
132
  case 2: return [2 /*return*/];
128
133
  }
129
134
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biz-slide-core",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {