@spinajs/rbac-http-user 2.0.511 → 2.0.513
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.
- package/lib/cjs/controllers/UserMetadataController.d.ts +2 -2
- package/lib/cjs/controllers/UserMetadataController.d.ts.map +1 -1
- package/lib/cjs/controllers/UserMetadataController.js +13 -11
- package/lib/cjs/controllers/UserMetadataController.js.map +1 -1
- package/lib/cjs/services/UserMetadataService.d.ts +26 -8
- package/lib/cjs/services/UserMetadataService.d.ts.map +1 -1
- package/lib/cjs/services/UserMetadataService.js +39 -13
- package/lib/cjs/services/UserMetadataService.js.map +1 -1
- package/lib/mjs/controllers/UserMetadataController.d.ts +2 -2
- package/lib/mjs/controllers/UserMetadataController.d.ts.map +1 -1
- package/lib/mjs/controllers/UserMetadataController.js +15 -13
- package/lib/mjs/controllers/UserMetadataController.js.map +1 -1
- package/lib/mjs/services/UserMetadataService.d.ts +26 -8
- package/lib/mjs/services/UserMetadataService.d.ts.map +1 -1
- package/lib/mjs/services/UserMetadataService.js +38 -13
- package/lib/mjs/services/UserMetadataService.js.map +1 -1
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +15 -15
|
@@ -54,7 +54,7 @@ export declare class UserMetadataController extends BaseController {
|
|
|
54
54
|
* @response 403 Forbidden — updateAny permission required
|
|
55
55
|
* @response 404 User not found
|
|
56
56
|
*/
|
|
57
|
-
addUserMetadata(user: UserModel,
|
|
57
|
+
addUserMetadata(user: UserModel, data: UserMetadataDto): Promise<Ok<any>>;
|
|
58
58
|
/**
|
|
59
59
|
* Update a metadata entry for a specific user (admin)
|
|
60
60
|
* Updates Key, Value, and Type of an existing metadata entry identified by Id or Key.
|
|
@@ -112,7 +112,7 @@ export declare class UserMetadataController extends BaseController {
|
|
|
112
112
|
* @response 401 Unauthorized — valid session required
|
|
113
113
|
* @response 403 Forbidden — updateOwn permission required
|
|
114
114
|
*/
|
|
115
|
-
addMetadata(user: UserModel,
|
|
115
|
+
addMetadata(user: UserModel, data: UserMetadataDto): Promise<Ok<any>>;
|
|
116
116
|
/**
|
|
117
117
|
* Update own metadata entry
|
|
118
118
|
* Updates Key, Value, and Type of an existing metadata entry identified by Id or Key.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserMetadataController.d.ts","sourceRoot":"","sources":["../../../src/controllers/UserMetadataController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,EAAE,EAAwC,cAAc,EAAS,MAAM,eAAe,CAAC;AAChH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGhE,OAAO,
|
|
1
|
+
{"version":3,"file":"UserMetadataController.d.ts","sourceRoot":"","sources":["../../../src/controllers/UserMetadataController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,EAAE,EAAwC,cAAc,EAAS,MAAM,eAAe,CAAC;AAChH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGhE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAU,cAAc,EAAa,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAmB,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAE1F;;;;;;;;;;GAUG;AACH,qBAGa,sBAAuB,SAAQ,cAAc;IAGtD,SAAS,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IAExC;;;;;;;;;;;;;OAaG;IAGU,YAAY,CACc,IAAI,EAAE,SAAS,EACzC,UAAU,CAAC,EAAE,aAAa,EAC1B,KAAK,CAAC,EAAE,QAAQ,EAEzB,MAAM,CAAC,EAAE,cAAc,yHAG1B;IAGD;;;;;;;;;;OAUG;IAGU,WAAW,CACe,IAAI,EAAE,SAAS,EACzC,GAAG,EAAE,MAAM,6BAEvB;IAED;;;;;;;;;OASG;IAGU,eAAe,CACW,IAAI,EAAE,SAAS,EAC1C,IAAI,EAAE,eAAe,oBAIhC;IAED;;;;;;;;;;;OAWG;IAGU,kBAAkB,CASxB,IAAI,EAAE,YAAY,EACc,KAAK,EAAE,SAAS,EAC3C,IAAI,EAAE,eAAe,oBAQhC;IAED;;;;;;;;;;OAUG;IAGU,kBAAkB,CACQ,IAAI,EAAE,SAAS,EACzC,IAAI,EAAE,MAAM,oBAIxB;IAED;;;;;;;;;;;OAWG;IAGU,QAAQ,CACT,IAAI,EAAE,SAAS,EACd,UAAU,CAAC,EAAE,aAAa,EAC1B,KAAK,CAAC,EAAE,QAAQ,EAEzB,MAAM,CAAC,EAAE,cAAc,yHAG1B;IAED;;;;;;;;;OASG;IAGU,OAAO,CAAS,IAAI,EAAE,SAAS,EAAW,GAAG,EAAE,MAAM,6BAEjE;IAED;;;;;;;OAOG;IAGU,WAAW,CAAS,IAAI,EAAE,SAAS,EAAU,IAAI,EAAE,eAAe,oBAG9E;IAED;;;;;;;;;;OAUG;IAGU,cAAc,CAAS,IAAI,EAAE,SAAS,EAAW,IAAI,EAAE,MAAM,EAAU,IAAI,EAAE,eAAe,oBAIxG;IAED;;;;;;;;;OASG;IAGU,cAAc,CAAS,IAAI,EAAE,SAAS,EAAW,IAAI,EAAE,MAAM,oBAIzE;CACJ"}
|
|
@@ -74,8 +74,8 @@ let UserMetadataController = class UserMetadataController extends http_1.BaseCon
|
|
|
74
74
|
* @response 403 Forbidden — updateAny permission required
|
|
75
75
|
* @response 404 User not found
|
|
76
76
|
*/
|
|
77
|
-
async addUserMetadata(user,
|
|
78
|
-
await this.Metadata.upsert(user.Id,
|
|
77
|
+
async addUserMetadata(user, data) {
|
|
78
|
+
await this.Metadata.upsert(user.Id, data);
|
|
79
79
|
return new http_1.Ok();
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
@@ -148,8 +148,8 @@ let UserMetadataController = class UserMetadataController extends http_1.BaseCon
|
|
|
148
148
|
* @response 401 Unauthorized — valid session required
|
|
149
149
|
* @response 403 Forbidden — updateOwn permission required
|
|
150
150
|
*/
|
|
151
|
-
async addMetadata(user,
|
|
152
|
-
await this.Metadata.upsert(user.Id,
|
|
151
|
+
async addMetadata(user, data) {
|
|
152
|
+
await this.Metadata.upsert(user.Id, data);
|
|
153
153
|
return new http_1.Ok();
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
@@ -211,19 +211,21 @@ __decorate([
|
|
|
211
211
|
(0, http_1.Post)(":user/metadata"),
|
|
212
212
|
(0, rbac_http_1.Permission)(['updateAny']),
|
|
213
213
|
__param(0, (0, orm_http_1.FromModel)({ queryField: "Uuid" })),
|
|
214
|
-
__param(1, (0,
|
|
214
|
+
__param(1, (0, http_1.Body)()),
|
|
215
215
|
__metadata("design:type", Function),
|
|
216
|
-
__metadata("design:paramtypes", [rbac_1.User,
|
|
216
|
+
__metadata("design:paramtypes", [rbac_1.User, metadata_dto_js_1.UserMetadataDto]),
|
|
217
217
|
__metadata("design:returntype", Promise)
|
|
218
218
|
], UserMetadataController.prototype, "addUserMetadata", null);
|
|
219
219
|
__decorate([
|
|
220
220
|
(0, http_1.Patch)(':_user/metadata/:meta'),
|
|
221
221
|
(0, rbac_http_1.Permission)(['updateAny']),
|
|
222
222
|
__param(0, (0, orm_http_1.FromModel)({
|
|
223
|
+
// ONE column, picked by the identifier's shape — see `addressedColumn`. Comparing both
|
|
224
|
+
// in an `OR` put a numeric id against the `Key` varchar, which MySQL then refused in
|
|
225
|
+
// the UPDATE this lookup feeds (`ER_TRUNCATED_WRONG_VALUE`), turning every
|
|
226
|
+
// id-addressed edit into a 500.
|
|
223
227
|
query: (function ([_, user], meta) {
|
|
224
|
-
return this.where(
|
|
225
|
-
this.where("Key", meta).orWhere("Id", meta);
|
|
226
|
-
}).andWhere("user_id", user.Id);
|
|
228
|
+
return this.where((0, UserMetadataService_js_1.addressedColumn)(meta), meta).andWhere("user_id", user.Id);
|
|
227
229
|
})
|
|
228
230
|
})),
|
|
229
231
|
__param(1, (0, orm_http_1.FromModel)({ queryField: "Uuid" })),
|
|
@@ -265,9 +267,9 @@ __decorate([
|
|
|
265
267
|
(0, http_1.Post)("metadata"),
|
|
266
268
|
(0, rbac_http_1.Permission)(['updateOwn']),
|
|
267
269
|
__param(0, (0, rbac_http_1.User)()),
|
|
268
|
-
__param(1, (0,
|
|
270
|
+
__param(1, (0, http_1.Body)()),
|
|
269
271
|
__metadata("design:type", Function),
|
|
270
|
-
__metadata("design:paramtypes", [rbac_1.User,
|
|
272
|
+
__metadata("design:paramtypes", [rbac_1.User, metadata_dto_js_1.UserMetadataDto]),
|
|
271
273
|
__metadata("design:returntype", Promise)
|
|
272
274
|
], UserMetadataController.prototype, "addMetadata", null);
|
|
273
275
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserMetadataController.js","sourceRoot":"","sources":["../../../src/controllers/UserMetadataController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wCAAgH;AAChH,wCAAgE;AAChE,oCAAyC;AACzC,kDAAkF;AAClF,
|
|
1
|
+
{"version":3,"file":"UserMetadataController.js","sourceRoot":"","sources":["../../../src/controllers/UserMetadataController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wCAAgH;AAChH,wCAAgE;AAChE,oCAAyC;AACzC,kDAAkF;AAClF,gDAA+F;AAC/F,4DAAyD;AACzD,mFAA6E;AAC7E,+EAA0F;AAE1F;;;;;;;;;;GAUG;AAII,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,qBAAc;IAKtD;;;;;;;;;;;;;OAaG;IAGU,AAAN,KAAK,CAAC,YAAY,CACc,IAAe,EACzC,UAA0B,EAC1B,KAAgB,EAEzB,MAAuB;QAEvB,OAAO,IAAI,SAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,UAA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gBAAI,GAAE,CAAA;IAAmB,WAAA,IAAA,YAAK,GAAE,CAAA;;qCAAnB,WAAS;;4DAIlD;iCAzNQ,sBAAsB;IAHlC,IAAA,eAAQ,EAAC,MAAM,CAAC;IAChB,IAAA,oBAAQ,EAAC,eAAe,CAAC;IACzB,IAAA,aAAM,EAAC,4BAAgB,CAAC;GACZ,sBAAsB,CA0NlC"}
|
|
@@ -8,6 +8,18 @@ import type { UserMetadataDto } from '../dto/metadata-dto.js';
|
|
|
8
8
|
* so plain listing requests failed instead of returning the first page.
|
|
9
9
|
*/
|
|
10
10
|
export declare const DEFAULT_PAGE_SIZE = 10;
|
|
11
|
+
/**
|
|
12
|
+
* Which column an "Id or Key" identifier addresses.
|
|
13
|
+
*
|
|
14
|
+
* `Id` is an integer column and `Key` a varchar one, so the two can never be compared against the
|
|
15
|
+
* same value in one predicate without the database coercing across types. Digits mean the id — a
|
|
16
|
+
* metadata key is a name (`user:niceName`, `2fa:enabled`), never a bare number — and anything else
|
|
17
|
+
* means the key.
|
|
18
|
+
*
|
|
19
|
+
* Exported because the admin route's `@FromModel` lookup has to address the entry exactly the way
|
|
20
|
+
* the write below does; the two disagreeing would turn a resolved entry into an update of nothing.
|
|
21
|
+
*/
|
|
22
|
+
export declare function addressedColumn(idOrKey: string | number): 'Id' | 'Key';
|
|
11
23
|
/**
|
|
12
24
|
* User metadata access, always scoped to one owner.
|
|
13
25
|
*
|
|
@@ -28,17 +40,23 @@ export declare class UserMetadataService {
|
|
|
28
40
|
/**
|
|
29
41
|
* Insert an entry, or update it when the key already exists.
|
|
30
42
|
*
|
|
31
|
-
*
|
|
32
|
-
* body
|
|
43
|
+
* Takes the DTO rather than a hydrated model: the model carries `user_id`, and exposing it on the
|
|
44
|
+
* request body published an owner id that callers must not set — clients then had to invent one
|
|
45
|
+
* to satisfy the generated schema. Ownership comes from the addressed user and nothing else.
|
|
33
46
|
*/
|
|
34
|
-
upsert(ownerId: number,
|
|
47
|
+
upsert(ownerId: number, data: UserMetadataDto): Promise<void>;
|
|
35
48
|
/**
|
|
36
|
-
* Update an entry addressed by either its Id or its Key
|
|
49
|
+
* Update an entry addressed by either its Id or its Key, always AND-ed with the ownership filter
|
|
50
|
+
* so no caller can reach another user's entry.
|
|
51
|
+
*
|
|
52
|
+
* ONE column is compared, chosen by {@link addressedColumn} — never both in an `OR`. The previous
|
|
53
|
+
* `Key = ? OR Id = ?` put a single value against columns of two different types, and a numeric
|
|
54
|
+
* identifier then had to be coerced against the `Key` varchar:
|
|
37
55
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
56
|
+
* - MySQL refuses that inside an UPDATE (`ER_TRUNCATED_WRONG_VALUE: Truncated incorrect DOUBLE
|
|
57
|
+
* value: 'user:phone'`), so every id-addressed update answered a 500;
|
|
58
|
+
* - databases that do coerce silently widen the match to any entry whose key reads as that
|
|
59
|
+
* number, so one update could rewrite two rows.
|
|
42
60
|
*/
|
|
43
61
|
update(ownerId: number, idOrKey: string | number, data: UserMetadataDto): Promise<void>;
|
|
44
62
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserMetadataService.d.ts","sourceRoot":"","sources":["../../../src/services/UserMetadataService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC;;;;;;;;;;;GAWG;AACH,qBACa,mBAAmB;IAC9B,mEAAmE;IAC5D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,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,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9D;CACF"}
|
|
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.UserMetadataService = exports.DEFAULT_PAGE_SIZE = void 0;
|
|
10
|
+
exports.addressedColumn = addressedColumn;
|
|
10
11
|
const di_1 = require("@spinajs/di");
|
|
11
12
|
const rbac_1 = require("@spinajs/rbac");
|
|
12
13
|
const orm_1 = require("@spinajs/orm");
|
|
@@ -17,6 +18,20 @@ const FilterableUserMetadata_js_1 = require("../models/FilterableUserMetadata.js
|
|
|
17
18
|
* so plain listing requests failed instead of returning the first page.
|
|
18
19
|
*/
|
|
19
20
|
exports.DEFAULT_PAGE_SIZE = 10;
|
|
21
|
+
/**
|
|
22
|
+
* Which column an "Id or Key" identifier addresses.
|
|
23
|
+
*
|
|
24
|
+
* `Id` is an integer column and `Key` a varchar one, so the two can never be compared against the
|
|
25
|
+
* same value in one predicate without the database coercing across types. Digits mean the id — a
|
|
26
|
+
* metadata key is a name (`user:niceName`, `2fa:enabled`), never a bare number — and anything else
|
|
27
|
+
* means the key.
|
|
28
|
+
*
|
|
29
|
+
* Exported because the admin route's `@FromModel` lookup has to address the entry exactly the way
|
|
30
|
+
* the write below does; the two disagreeing would turn a resolved entry into an update of nothing.
|
|
31
|
+
*/
|
|
32
|
+
function addressedColumn(idOrKey) {
|
|
33
|
+
return typeof idOrKey === 'number' || /^\d+$/.test(idOrKey) ? 'Id' : 'Key';
|
|
34
|
+
}
|
|
20
35
|
/**
|
|
21
36
|
* User metadata access, always scoped to one owner.
|
|
22
37
|
*
|
|
@@ -50,20 +65,33 @@ let UserMetadataService = class UserMetadataService {
|
|
|
50
65
|
/**
|
|
51
66
|
* Insert an entry, or update it when the key already exists.
|
|
52
67
|
*
|
|
53
|
-
*
|
|
54
|
-
* body
|
|
68
|
+
* Takes the DTO rather than a hydrated model: the model carries `user_id`, and exposing it on the
|
|
69
|
+
* request body published an owner id that callers must not set — clients then had to invent one
|
|
70
|
+
* to satisfy the generated schema. Ownership comes from the addressed user and nothing else.
|
|
55
71
|
*/
|
|
56
|
-
async upsert(ownerId,
|
|
57
|
-
|
|
58
|
-
|
|
72
|
+
async upsert(ownerId, data) {
|
|
73
|
+
const entry = new rbac_1.UserMetadata();
|
|
74
|
+
entry.Key = data.Key;
|
|
75
|
+
// `Value` is a setter that derives `Type` from the JS type of what it is given, so the declared
|
|
76
|
+
// type is assigned AFTER it — otherwise a 'json' or 'datetime' entry sent as a string would be
|
|
77
|
+
// written as 'string'.
|
|
78
|
+
entry.Value = data.Value;
|
|
79
|
+
entry.Type = data.Type;
|
|
80
|
+
entry.user_id = ownerId;
|
|
81
|
+
await entry.insert(orm_1.InsertBehaviour.InsertOrUpdate);
|
|
59
82
|
}
|
|
60
83
|
/**
|
|
61
|
-
* Update an entry addressed by either its Id or its Key
|
|
84
|
+
* Update an entry addressed by either its Id or its Key, always AND-ed with the ownership filter
|
|
85
|
+
* so no caller can reach another user's entry.
|
|
86
|
+
*
|
|
87
|
+
* ONE column is compared, chosen by {@link addressedColumn} — never both in an `OR`. The previous
|
|
88
|
+
* `Key = ? OR Id = ?` put a single value against columns of two different types, and a numeric
|
|
89
|
+
* identifier then had to be coerced against the `Key` varchar:
|
|
62
90
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
91
|
+
* - MySQL refuses that inside an UPDATE (`ER_TRUNCATED_WRONG_VALUE: Truncated incorrect DOUBLE
|
|
92
|
+
* value: 'user:phone'`), so every id-addressed update answered a 500;
|
|
93
|
+
* - databases that do coerce silently widen the match to any entry whose key reads as that
|
|
94
|
+
* number, so one update could rewrite two rows.
|
|
67
95
|
*/
|
|
68
96
|
async update(ownerId, idOrKey, data) {
|
|
69
97
|
await rbac_1.UserMetadata.update({
|
|
@@ -71,9 +99,7 @@ let UserMetadataService = class UserMetadataService {
|
|
|
71
99
|
Value: data.Value,
|
|
72
100
|
Type: data.Type,
|
|
73
101
|
})
|
|
74
|
-
.where(
|
|
75
|
-
this.where('Key', idOrKey).orWhere('Id', idOrKey);
|
|
76
|
-
})
|
|
102
|
+
.where(addressedColumn(idOrKey), idOrKey)
|
|
77
103
|
.andWhere('user_id', ownerId);
|
|
78
104
|
}
|
|
79
105
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserMetadataService.js","sourceRoot":"","sources":["../../../src/services/UserMetadataService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UserMetadataService.js","sourceRoot":"","sources":["../../../src/services/UserMetadataService.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,oCAAyC;AACzC,wCAA6C;AAC7C,sCAA0D;AAE1D,mFAA6E;AAG7E;;;;GAIG;AACU,QAAA,iBAAiB,GAAG,EAAE,CAAC;AAEpC;;;;;;;;;;GAUG;AACH,yBAAgC,OAAwB;IACtD,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AAC7E,CAAC;AAED;;;;;;;;;;;GAWG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,mEAAmE;IAC5D,IAAI,CAAC,OAAe,EAAE,UAA0B,EAAE,KAAgB,EAAE,MAAuB;QAChG,MAAM,KAAK,GAAG,UAAU,EAAE,KAAK,IAAI,QAAA,iBAAiB,CAAC;QAErD,OAAO,kDAAsB,CAAC,MAAM,EAAE;aACnC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC;aACzB,MAAM,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC;aACzC,IAAI,CAAC,KAAK,CAAC;aACX,IAAI,CAAC,KAAK,GAAG,CAAC,UAAU,EAA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,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;CACF,CAAA;;8BA3EY,mBAAmB;IAD/B,IAAA,eAAU,GAAE;GACA,mBAAmB,CA2E/B"}
|
|
@@ -54,7 +54,7 @@ export declare class UserMetadataController extends BaseController {
|
|
|
54
54
|
* @response 403 Forbidden — updateAny permission required
|
|
55
55
|
* @response 404 User not found
|
|
56
56
|
*/
|
|
57
|
-
addUserMetadata(user: UserModel,
|
|
57
|
+
addUserMetadata(user: UserModel, data: UserMetadataDto): Promise<Ok<any>>;
|
|
58
58
|
/**
|
|
59
59
|
* Update a metadata entry for a specific user (admin)
|
|
60
60
|
* Updates Key, Value, and Type of an existing metadata entry identified by Id or Key.
|
|
@@ -112,7 +112,7 @@ export declare class UserMetadataController extends BaseController {
|
|
|
112
112
|
* @response 401 Unauthorized — valid session required
|
|
113
113
|
* @response 403 Forbidden — updateOwn permission required
|
|
114
114
|
*/
|
|
115
|
-
addMetadata(user: UserModel,
|
|
115
|
+
addMetadata(user: UserModel, data: UserMetadataDto): Promise<Ok<any>>;
|
|
116
116
|
/**
|
|
117
117
|
* Update own metadata entry
|
|
118
118
|
* Updates Key, Value, and Type of an existing metadata entry identified by Id or Key.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserMetadataController.d.ts","sourceRoot":"","sources":["../../../src/controllers/UserMetadataController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,EAAE,EAAwC,cAAc,EAAS,MAAM,eAAe,CAAC;AAChH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGhE,OAAO,
|
|
1
|
+
{"version":3,"file":"UserMetadataController.d.ts","sourceRoot":"","sources":["../../../src/controllers/UserMetadataController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,EAAE,EAAwC,cAAc,EAAS,MAAM,eAAe,CAAC;AAChH,OAAO,EAAE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,IAAI,EAAE,SAAS,EAAU,IAAI,EAAE,eAAe,oBAG9E;IAED;;;;;;;;;;OAUG;IAGU,cAAc,CAAS,IAAI,EAAE,SAAS,EAAW,IAAI,EAAE,MAAM,EAAU,IAAI,EAAE,eAAe,oBAIxG;IAED;;;;;;;;;OASG;IAGU,cAAc,CAAS,IAAI,EAAE,SAAS,EAAW,IAAI,EAAE,MAAM,oBAIzE;CACJ"}
|
|
@@ -14,10 +14,10 @@ import { Post, BasePath, Ok, Del, Body, Get, Query, Param, Policy, BaseControlle
|
|
|
14
14
|
import { User as UserModel, UserMetadata } from '@spinajs/rbac';
|
|
15
15
|
import { Autoinject } from '@spinajs/di';
|
|
16
16
|
import { AuthorizedPolicy, Permission, Resource, User } from '@spinajs/rbac-http';
|
|
17
|
-
import {
|
|
17
|
+
import { PaginationDTO, OrderDTO, Filter, FromModel } from '@spinajs/orm-http';
|
|
18
18
|
import { UserMetadataDto } from '../dto/metadata-dto.js';
|
|
19
19
|
import { FilterableUserMetadata } from '../models/FilterableUserMetadata.js';
|
|
20
|
-
import { UserMetadataService } from '../services/UserMetadataService.js';
|
|
20
|
+
import { addressedColumn, UserMetadataService } from '../services/UserMetadataService.js';
|
|
21
21
|
/**
|
|
22
22
|
* User metadata management.
|
|
23
23
|
* Provides CRUD operations for key-value metadata entries attached to user accounts.
|
|
@@ -71,8 +71,8 @@ let UserMetadataController = class UserMetadataController extends BaseController
|
|
|
71
71
|
* @response 403 Forbidden — updateAny permission required
|
|
72
72
|
* @response 404 User not found
|
|
73
73
|
*/
|
|
74
|
-
async addUserMetadata(user,
|
|
75
|
-
await this.Metadata.upsert(user.Id,
|
|
74
|
+
async addUserMetadata(user, data) {
|
|
75
|
+
await this.Metadata.upsert(user.Id, data);
|
|
76
76
|
return new Ok();
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
@@ -145,8 +145,8 @@ let UserMetadataController = class UserMetadataController extends BaseController
|
|
|
145
145
|
* @response 401 Unauthorized — valid session required
|
|
146
146
|
* @response 403 Forbidden — updateOwn permission required
|
|
147
147
|
*/
|
|
148
|
-
async addMetadata(user,
|
|
149
|
-
await this.Metadata.upsert(user.Id,
|
|
148
|
+
async addMetadata(user, data) {
|
|
149
|
+
await this.Metadata.upsert(user.Id, data);
|
|
150
150
|
return new Ok();
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
@@ -209,20 +209,22 @@ __decorate([
|
|
|
209
209
|
Post(":user/metadata"),
|
|
210
210
|
Permission(['updateAny']),
|
|
211
211
|
__param(0, FromModel({ queryField: "Uuid" })),
|
|
212
|
-
__param(1,
|
|
212
|
+
__param(1, Body()),
|
|
213
213
|
__metadata("design:type", Function),
|
|
214
214
|
__metadata("design:paramtypes", [UserModel,
|
|
215
|
-
|
|
215
|
+
UserMetadataDto]),
|
|
216
216
|
__metadata("design:returntype", Promise)
|
|
217
217
|
], UserMetadataController.prototype, "addUserMetadata", null);
|
|
218
218
|
__decorate([
|
|
219
219
|
Patch(':_user/metadata/:meta'),
|
|
220
220
|
Permission(['updateAny']),
|
|
221
221
|
__param(0, FromModel({
|
|
222
|
+
// ONE column, picked by the identifier's shape — see `addressedColumn`. Comparing both
|
|
223
|
+
// in an `OR` put a numeric id against the `Key` varchar, which MySQL then refused in
|
|
224
|
+
// the UPDATE this lookup feeds (`ER_TRUNCATED_WRONG_VALUE`), turning every
|
|
225
|
+
// id-addressed edit into a 500.
|
|
222
226
|
query: (function ([_, user], meta) {
|
|
223
|
-
return this.where(
|
|
224
|
-
this.where("Key", meta).orWhere("Id", meta);
|
|
225
|
-
}).andWhere("user_id", user.Id);
|
|
227
|
+
return this.where(addressedColumn(meta), meta).andWhere("user_id", user.Id);
|
|
226
228
|
})
|
|
227
229
|
})),
|
|
228
230
|
__param(1, FromModel({ queryField: "Uuid" })),
|
|
@@ -268,9 +270,9 @@ __decorate([
|
|
|
268
270
|
Post("metadata"),
|
|
269
271
|
Permission(['updateOwn']),
|
|
270
272
|
__param(0, User()),
|
|
271
|
-
__param(1,
|
|
273
|
+
__param(1, Body()),
|
|
272
274
|
__metadata("design:type", Function),
|
|
273
|
-
__metadata("design:paramtypes", [UserModel,
|
|
275
|
+
__metadata("design:paramtypes", [UserModel, UserMetadataDto]),
|
|
274
276
|
__metadata("design:returntype", Promise)
|
|
275
277
|
], UserMetadataController.prototype, "addMetadata", null);
|
|
276
278
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserMetadataController.js","sourceRoot":"","sources":["../../../src/controllers/UserMetadataController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"UserMetadataController.js","sourceRoot":"","sources":["../../../src/controllers/UserMetadataController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;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IACG,WAAA,IAAI,EAAE,CAAA;IAAmB,WAAA,KAAK,EAAE,CAAA;IAAgB,WAAA,IAAI,EAAE,CAAA;;qCAAzC,SAAS,UAAuC,eAAe;;4DAIxG;AAcY;IAFZ,GAAG,CAAC,gBAAgB,CAAC;IACrB,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC;IACG,WAAA,IAAI,EAAE,CAAA;IAAmB,WAAA,KAAK,EAAE,CAAA;;qCAAnB,SAAS;;4DAIlD;AAzNQ,sBAAsB;IAHlC,QAAQ,CAAC,MAAM,CAAC;IAChB,QAAQ,CAAC,eAAe,CAAC;IACzB,MAAM,CAAC,gBAAgB,CAAC;GACZ,sBAAsB,CA0NlC"}
|
|
@@ -8,6 +8,18 @@ import type { UserMetadataDto } from '../dto/metadata-dto.js';
|
|
|
8
8
|
* so plain listing requests failed instead of returning the first page.
|
|
9
9
|
*/
|
|
10
10
|
export declare const DEFAULT_PAGE_SIZE = 10;
|
|
11
|
+
/**
|
|
12
|
+
* Which column an "Id or Key" identifier addresses.
|
|
13
|
+
*
|
|
14
|
+
* `Id` is an integer column and `Key` a varchar one, so the two can never be compared against the
|
|
15
|
+
* same value in one predicate without the database coercing across types. Digits mean the id — a
|
|
16
|
+
* metadata key is a name (`user:niceName`, `2fa:enabled`), never a bare number — and anything else
|
|
17
|
+
* means the key.
|
|
18
|
+
*
|
|
19
|
+
* Exported because the admin route's `@FromModel` lookup has to address the entry exactly the way
|
|
20
|
+
* the write below does; the two disagreeing would turn a resolved entry into an update of nothing.
|
|
21
|
+
*/
|
|
22
|
+
export declare function addressedColumn(idOrKey: string | number): 'Id' | 'Key';
|
|
11
23
|
/**
|
|
12
24
|
* User metadata access, always scoped to one owner.
|
|
13
25
|
*
|
|
@@ -28,17 +40,23 @@ export declare class UserMetadataService {
|
|
|
28
40
|
/**
|
|
29
41
|
* Insert an entry, or update it when the key already exists.
|
|
30
42
|
*
|
|
31
|
-
*
|
|
32
|
-
* body
|
|
43
|
+
* Takes the DTO rather than a hydrated model: the model carries `user_id`, and exposing it on the
|
|
44
|
+
* request body published an owner id that callers must not set — clients then had to invent one
|
|
45
|
+
* to satisfy the generated schema. Ownership comes from the addressed user and nothing else.
|
|
33
46
|
*/
|
|
34
|
-
upsert(ownerId: number,
|
|
47
|
+
upsert(ownerId: number, data: UserMetadataDto): Promise<void>;
|
|
35
48
|
/**
|
|
36
|
-
* Update an entry addressed by either its Id or its Key
|
|
49
|
+
* Update an entry addressed by either its Id or its Key, always AND-ed with the ownership filter
|
|
50
|
+
* so no caller can reach another user's entry.
|
|
51
|
+
*
|
|
52
|
+
* ONE column is compared, chosen by {@link addressedColumn} — never both in an `OR`. The previous
|
|
53
|
+
* `Key = ? OR Id = ?` put a single value against columns of two different types, and a numeric
|
|
54
|
+
* identifier then had to be coerced against the `Key` varchar:
|
|
37
55
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
56
|
+
* - MySQL refuses that inside an UPDATE (`ER_TRUNCATED_WRONG_VALUE: Truncated incorrect DOUBLE
|
|
57
|
+
* value: 'user:phone'`), so every id-addressed update answered a 500;
|
|
58
|
+
* - databases that do coerce silently widen the match to any entry whose key reads as that
|
|
59
|
+
* number, so one update could rewrite two rows.
|
|
42
60
|
*/
|
|
43
61
|
update(ownerId: number, idOrKey: string | number, data: UserMetadataDto): Promise<void>;
|
|
44
62
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserMetadataService.d.ts","sourceRoot":"","sources":["../../../src/services/UserMetadataService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;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OAYG;IACU,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAQnG;IAED;;;;;;OAMG;IACU,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9D;CACF"}
|
|
@@ -14,6 +14,20 @@ import { FilterableUserMetadata } from '../models/FilterableUserMetadata.js';
|
|
|
14
14
|
* so plain listing requests failed instead of returning the first page.
|
|
15
15
|
*/
|
|
16
16
|
export const DEFAULT_PAGE_SIZE = 10;
|
|
17
|
+
/**
|
|
18
|
+
* Which column an "Id or Key" identifier addresses.
|
|
19
|
+
*
|
|
20
|
+
* `Id` is an integer column and `Key` a varchar one, so the two can never be compared against the
|
|
21
|
+
* same value in one predicate without the database coercing across types. Digits mean the id — a
|
|
22
|
+
* metadata key is a name (`user:niceName`, `2fa:enabled`), never a bare number — and anything else
|
|
23
|
+
* means the key.
|
|
24
|
+
*
|
|
25
|
+
* Exported because the admin route's `@FromModel` lookup has to address the entry exactly the way
|
|
26
|
+
* the write below does; the two disagreeing would turn a resolved entry into an update of nothing.
|
|
27
|
+
*/
|
|
28
|
+
export function addressedColumn(idOrKey) {
|
|
29
|
+
return typeof idOrKey === 'number' || /^\d+$/.test(idOrKey) ? 'Id' : 'Key';
|
|
30
|
+
}
|
|
17
31
|
/**
|
|
18
32
|
* User metadata access, always scoped to one owner.
|
|
19
33
|
*
|
|
@@ -47,20 +61,33 @@ let UserMetadataService = class UserMetadataService {
|
|
|
47
61
|
/**
|
|
48
62
|
* Insert an entry, or update it when the key already exists.
|
|
49
63
|
*
|
|
50
|
-
*
|
|
51
|
-
* body
|
|
64
|
+
* Takes the DTO rather than a hydrated model: the model carries `user_id`, and exposing it on the
|
|
65
|
+
* request body published an owner id that callers must not set — clients then had to invent one
|
|
66
|
+
* to satisfy the generated schema. Ownership comes from the addressed user and nothing else.
|
|
52
67
|
*/
|
|
53
|
-
async upsert(ownerId,
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
async upsert(ownerId, data) {
|
|
69
|
+
const entry = new UserMetadata();
|
|
70
|
+
entry.Key = data.Key;
|
|
71
|
+
// `Value` is a setter that derives `Type` from the JS type of what it is given, so the declared
|
|
72
|
+
// type is assigned AFTER it — otherwise a 'json' or 'datetime' entry sent as a string would be
|
|
73
|
+
// written as 'string'.
|
|
74
|
+
entry.Value = data.Value;
|
|
75
|
+
entry.Type = data.Type;
|
|
76
|
+
entry.user_id = ownerId;
|
|
77
|
+
await entry.insert(InsertBehaviour.InsertOrUpdate);
|
|
56
78
|
}
|
|
57
79
|
/**
|
|
58
|
-
* Update an entry addressed by either its Id or its Key
|
|
80
|
+
* Update an entry addressed by either its Id or its Key, always AND-ed with the ownership filter
|
|
81
|
+
* so no caller can reach another user's entry.
|
|
82
|
+
*
|
|
83
|
+
* ONE column is compared, chosen by {@link addressedColumn} — never both in an `OR`. The previous
|
|
84
|
+
* `Key = ? OR Id = ?` put a single value against columns of two different types, and a numeric
|
|
85
|
+
* identifier then had to be coerced against the `Key` varchar:
|
|
59
86
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
87
|
+
* - MySQL refuses that inside an UPDATE (`ER_TRUNCATED_WRONG_VALUE: Truncated incorrect DOUBLE
|
|
88
|
+
* value: 'user:phone'`), so every id-addressed update answered a 500;
|
|
89
|
+
* - databases that do coerce silently widen the match to any entry whose key reads as that
|
|
90
|
+
* number, so one update could rewrite two rows.
|
|
64
91
|
*/
|
|
65
92
|
async update(ownerId, idOrKey, data) {
|
|
66
93
|
await UserMetadata.update({
|
|
@@ -68,9 +95,7 @@ let UserMetadataService = class UserMetadataService {
|
|
|
68
95
|
Value: data.Value,
|
|
69
96
|
Type: data.Type,
|
|
70
97
|
})
|
|
71
|
-
.where(
|
|
72
|
-
this.where('Key', idOrKey).orWhere('Id', idOrKey);
|
|
73
|
-
})
|
|
98
|
+
.where(addressedColumn(idOrKey), idOrKey)
|
|
74
99
|
.andWhere('user_id', ownerId);
|
|
75
100
|
}
|
|
76
101
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserMetadataService.js","sourceRoot":"","sources":["../../../src/services/UserMetadataService.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAG7E;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC;;;;;;;;;;;GAWG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,mEAAmE;IAC5D,IAAI,CAAC,OAAe,EAAE,UAA0B,EAAE,KAAgB,EAAE,MAAuB;QAChG,MAAM,KAAK,GAAG,UAAU,EAAE,KAAK,IAAI,iBAAiB,CAAC;QAErD,OAAO,sBAAsB,CAAC,MAAM,EAAE;aACnC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC;aACzB,MAAM,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC;aACzC,IAAI,CAAC,KAAK,CAAC;aACX,IAAI,CAAC,KAAK,GAAG,CAAC,UAAU,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC;aACrC,KAAK,CAAC,KAAK,EAAE,MAAM,IAAI,IAAI,EAAE,KAAK,EAAE,KAAK,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;IAClE,CAAC;IAED,+DAA+D;IACxD,QAAQ,CAAC,OAAe,EAAE,GAAW;QAC1C,OAAO,YAAY,CAAC,KAAK,CAAC;YACxB,GAAG,EAAE,GAAG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