@riocrypto/common-server 1.0.1577 → 1.0.1578

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.
@@ -1,3 +1,2 @@
1
- import { User } from "@riocrypto/common";
2
1
  import { CustomValidator } from "express-validator";
3
- export declare const requireAdminAuthIfDefined: (user: User) => CustomValidator;
2
+ export declare const requireAdminAuthIfDefined: CustomValidator;
@@ -1,15 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.requireAdminAuthIfDefined = void 0;
4
- const common_1 = require("@riocrypto/common");
5
- const requireAdminAuthIfDefined = (user) => (value, { req, path }) => {
4
+ const requireAdminAuthIfDefined = (value, { req, path }) => {
6
5
  if (value !== undefined &&
7
6
  value !== "" &&
8
7
  !req.adminAuth &&
9
8
  // @ts-ignore
10
- (user[path] !== undefined || user[path] !== "")) {
11
- throw new common_1.AdminOnlyError();
9
+ getValueByPath(req.userToUpdate, path) !== undefined &&
10
+ getValueByPath(req.userToUpdate, path) !== "" &&
11
+ // @ts-ignore
12
+ getValueByPath(req.userToUpdate, path) !== value) {
13
+ return false;
12
14
  }
13
15
  return true;
14
16
  };
15
17
  exports.requireAdminAuthIfDefined = requireAdminAuthIfDefined;
18
+ function getValueByPath(obj, path) {
19
+ const keys = path.split(".");
20
+ let current = obj;
21
+ for (let key of keys) {
22
+ // @ts-ignore
23
+ current = current[key];
24
+ }
25
+ return current;
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1577",
3
+ "version": "1.0.1578",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "@google-cloud/storage": "^6.9.5",
29
29
  "@google-cloud/vision": "^4.0.2",
30
30
  "@hyperdx/node-opentelemetry": "^0.4.2",
31
- "@riocrypto/common": "^1.0.1406",
31
+ "@riocrypto/common": "^1.0.1407",
32
32
  "@types/express": "^4.17.13",
33
33
  "axios": "^1.6.0",
34
34
  "ccxt": "^3.0.30",