@riocrypto/common-server 1.0.527 → 1.0.529
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.
|
@@ -33,9 +33,9 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
33
33
|
authorizationTypes.includes(common_1.AuthorizationType.UserOptional) ||
|
|
34
34
|
authorizationTypes.includes(common_1.AuthorizationType.Broker) ||
|
|
35
35
|
authorizationTypes.includes(common_1.AuthorizationType.Partner)) {
|
|
36
|
-
if ((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.
|
|
36
|
+
if ((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.accessToken) {
|
|
37
37
|
try {
|
|
38
|
-
const payload = jsonwebtoken_1.default.verify(req.cookies.
|
|
38
|
+
const payload = jsonwebtoken_1.default.verify(req.cookies.accessToken, process.env.JWT_KEY);
|
|
39
39
|
req.currentAuth = payload;
|
|
40
40
|
}
|
|
41
41
|
catch (err) { }
|
|
@@ -188,12 +188,12 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
188
188
|
}
|
|
189
189
|
if ((authorizationTypes.includes(common_1.AuthorizationType.User) ||
|
|
190
190
|
authorizationTypes.includes(common_1.AuthorizationType.UserNoKYC)) &&
|
|
191
|
-
((_g = req.cookies) === null || _g === void 0 ? void 0 : _g.
|
|
191
|
+
((_g = req.cookies) === null || _g === void 0 ? void 0 : _g.accessToken)) {
|
|
192
192
|
throw new common_1.MissingUserError();
|
|
193
193
|
}
|
|
194
194
|
if (authorizationTypes.includes(common_1.AuthorizationType.Admin) &&
|
|
195
195
|
authorizationTypes.length === 1 &&
|
|
196
|
-
((_h = req.cookies) === null || _h === void 0 ? void 0 : _h.
|
|
196
|
+
((_h = req.cookies) === null || _h === void 0 ? void 0 : _h.accessToken)) {
|
|
197
197
|
throw new common_1.AdminOnlyError();
|
|
198
198
|
}
|
|
199
199
|
if (!req.user && authorizationTypes.includes(common_1.AuthorizationType.Broker)) {
|
package/build/models/auth.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ interface AuthAttrs {
|
|
|
7
7
|
securityAnswer?: string;
|
|
8
8
|
previousPasswords?: string[];
|
|
9
9
|
apiKeys?: APIKey[];
|
|
10
|
+
isDisabled?: boolean;
|
|
10
11
|
}
|
|
11
12
|
interface AuthDoc extends Document {
|
|
12
13
|
phoneNumber: string;
|
|
@@ -15,6 +16,7 @@ interface AuthDoc extends Document {
|
|
|
15
16
|
securityAnswer?: string;
|
|
16
17
|
previousPasswords?: string[];
|
|
17
18
|
apiKeys?: APIKey[];
|
|
19
|
+
isDisabled?: boolean;
|
|
18
20
|
}
|
|
19
21
|
interface AuthModel extends Model<AuthDoc> {
|
|
20
22
|
build(attrs: AuthAttrs): AuthDoc;
|
package/build/models/auth.js
CHANGED