biz-slide-core 1.2.80 → 1.2.82
Sign up to get free protection for your applications and to get access to all the features.
package/entity/ppt.entity.js
CHANGED
@@ -11,6 +11,7 @@ var PPTSchema = new mongoose_1.Schema({
|
|
11
11
|
templateTypeId: { type: mongoose_1.Schema.Types.ObjectId, ref: "template-type" },
|
12
12
|
systemGeneratedtopics: { type: [String], default: [], _id: false },
|
13
13
|
userSelectedTopics: { type: [String], default: [], _id: false },
|
14
|
+
userLanguageTopics: { type: [String], default: [], _id: false },
|
14
15
|
userReaction: { type: Number, default: 0 },
|
15
16
|
userFeedback: { type: String, default: null },
|
16
17
|
colors: { type: [String], default: [], _id: false },
|
@@ -102,6 +102,28 @@ var authorize = function (roles) {
|
|
102
102
|
};
|
103
103
|
};
|
104
104
|
exports.authorize = authorize;
|
105
|
+
var createUser = function (emailId, userId, appName) { return __awaiter(void 0, void 0, void 0, function () {
|
106
|
+
var customer, newCustomer;
|
107
|
+
return __generator(this, function (_a) {
|
108
|
+
switch (_a.label) {
|
109
|
+
case 0: return [4 /*yield*/, entity_1.CustomerModel.findOne({ userId: userId })];
|
110
|
+
case 1:
|
111
|
+
customer = _a.sent();
|
112
|
+
if (!!customer) return [3 /*break*/, 3];
|
113
|
+
newCustomer = new entity_1.CustomerModel({
|
114
|
+
appName: appName,
|
115
|
+
emailId: emailId,
|
116
|
+
emailTemplateStatus: {},
|
117
|
+
userId: userId
|
118
|
+
});
|
119
|
+
return [4 /*yield*/, newCustomer.save()];
|
120
|
+
case 2:
|
121
|
+
_a.sent();
|
122
|
+
_a.label = 3;
|
123
|
+
case 3: return [2 /*return*/];
|
124
|
+
}
|
125
|
+
});
|
126
|
+
}); };
|
105
127
|
var authorizeWithSlideApp = function () {
|
106
128
|
return function (req, res, next) {
|
107
129
|
var _a;
|
@@ -115,7 +137,7 @@ var authorizeWithSlideApp = function () {
|
|
115
137
|
if (!req.headers.authorization) {
|
116
138
|
return [2 /*return*/, res.status(401).json({ message: 'Unauthorized' })];
|
117
139
|
}
|
118
|
-
if (!req.headers.authorization) return [3 /*break*/,
|
140
|
+
if (!req.headers.authorization) return [3 /*break*/, 3];
|
119
141
|
return [4 /*yield*/, (0, utilities_1.verifyUid)(req.headers.authorization)];
|
120
142
|
case 1:
|
121
143
|
token = _b.sent();
|
@@ -133,9 +155,12 @@ var authorizeWithSlideApp = function () {
|
|
133
155
|
appName: req.headers['x-app-name'],
|
134
156
|
email: (token === null || token === void 0 ? void 0 : token.customer_email) || ""
|
135
157
|
};
|
158
|
+
return [4 /*yield*/, createUser(req.user.email, req.user.userId, req.user.appName)];
|
159
|
+
case 2:
|
160
|
+
_b.sent();
|
136
161
|
next();
|
137
|
-
_b.label =
|
138
|
-
case
|
162
|
+
_b.label = 3;
|
163
|
+
case 3: return [2 /*return*/];
|
139
164
|
}
|
140
165
|
});
|
141
166
|
});
|
@@ -154,7 +179,7 @@ var nonAuthorizeWithSlideApp = function () {
|
|
154
179
|
sessionId = req.headers['x-fingerprint-key'];
|
155
180
|
userId = "guest";
|
156
181
|
email = "";
|
157
|
-
if (!req.headers.authorization) return [3 /*break*/,
|
182
|
+
if (!req.headers.authorization) return [3 /*break*/, 3];
|
158
183
|
return [4 /*yield*/, (0, utilities_1.verifyUid)(req.headers.authorization)];
|
159
184
|
case 1:
|
160
185
|
token = _b.sent();
|
@@ -166,13 +191,16 @@ var nonAuthorizeWithSlideApp = function () {
|
|
166
191
|
if (!userId) {
|
167
192
|
return [2 /*return*/, res.status(401).json({ message: 'userId not found' })];
|
168
193
|
}
|
169
|
-
return [
|
194
|
+
return [4 /*yield*/, createUser(email, userId, req.headers['x-app-name'])];
|
170
195
|
case 2:
|
196
|
+
_b.sent();
|
197
|
+
return [3 /*break*/, 4];
|
198
|
+
case 3:
|
171
199
|
if (!ipAddress || !sessionId) {
|
172
200
|
return [2 /*return*/, res.status(401).json({ message: 'We are not able to track your actions' })];
|
173
201
|
}
|
174
|
-
_b.label =
|
175
|
-
case
|
202
|
+
_b.label = 4;
|
203
|
+
case 4:
|
176
204
|
req.user = {
|
177
205
|
userId: userId,
|
178
206
|
sessionId: sessionId,
|