@nymphjs/tilmeld 1.0.0-beta.46 → 1.0.0-beta.47
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/CHANGELOG.md +4 -0
- package/README.md +1 -1
- package/package.json +24 -24
- package/src/AbleObject.ts +1 -1
- package/src/Group.test.ts +1 -1
- package/src/Group.ts +29 -29
- package/src/Tilmeld.ts +22 -22
- package/src/User.test.ts +1 -1
- package/src/User.ts +43 -43
- package/src/conf/d.ts +4 -4
- package/src/conf/defaults.ts +7 -7
- package/src/tilmeldJoiProps.ts +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.0.0-beta.47](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.46...v1.0.0-beta.47) (2023-11-10)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @nymphjs/tilmeld
|
|
9
|
+
|
|
6
10
|
# [1.0.0-beta.46](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.45...v1.0.0-beta.46) (2023-08-29)
|
|
7
11
|
|
|
8
12
|
### Bug Fixes
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nymphjs/tilmeld",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.47",
|
|
4
4
|
"description": "Nymph.js - Tilmeld User and Group System",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,35 +31,35 @@
|
|
|
31
31
|
},
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@nymphjs/guid": "^1.0.0-beta.
|
|
35
|
-
"@nymphjs/nymph": "^1.0.0-beta.
|
|
36
|
-
"crypto-js": "^4.
|
|
37
|
-
"email-templates": "^11.1.
|
|
34
|
+
"@nymphjs/guid": "^1.0.0-beta.47",
|
|
35
|
+
"@nymphjs/nymph": "^1.0.0-beta.47",
|
|
36
|
+
"crypto-js": "^4.2.0",
|
|
37
|
+
"email-templates": "^11.1.1",
|
|
38
38
|
"express": "^4.18.2",
|
|
39
|
-
"joi": "^17.
|
|
40
|
-
"jsonwebtoken": "^9.0.
|
|
39
|
+
"joi": "^17.11.0",
|
|
40
|
+
"jsonwebtoken": "^9.0.2",
|
|
41
41
|
"locutus": "^2.0.16",
|
|
42
42
|
"lodash": "^4.17.21",
|
|
43
|
-
"otpauth": "^9.1.
|
|
43
|
+
"otpauth": "^9.1.5",
|
|
44
44
|
"pug": "^3.0.2",
|
|
45
45
|
"qrcode": "^1.5.3"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@nymphjs/client": "^1.0.0-beta.
|
|
49
|
-
"@nymphjs/client-node": "^1.0.0-beta.
|
|
50
|
-
"@nymphjs/driver-sqlite3": "^1.0.0-beta.
|
|
51
|
-
"@tsconfig/recommended": "^1.0.
|
|
52
|
-
"@types/crypto-js": "^4.
|
|
53
|
-
"@types/email-templates": "^10.0.
|
|
54
|
-
"@types/express": "^4.17.
|
|
55
|
-
"@types/jest": "^29.5.
|
|
56
|
-
"@types/jsonwebtoken": "^9.0.
|
|
57
|
-
"@types/locutus": "^0.0.
|
|
58
|
-
"@types/lodash": "^4.14.
|
|
59
|
-
"@types/qrcode": "^1.5.
|
|
60
|
-
"jest": "^29.
|
|
61
|
-
"ts-jest": "^29.1.
|
|
62
|
-
"typescript": "^5.
|
|
48
|
+
"@nymphjs/client": "^1.0.0-beta.47",
|
|
49
|
+
"@nymphjs/client-node": "^1.0.0-beta.47",
|
|
50
|
+
"@nymphjs/driver-sqlite3": "^1.0.0-beta.47",
|
|
51
|
+
"@tsconfig/recommended": "^1.0.3",
|
|
52
|
+
"@types/crypto-js": "^4.2.1",
|
|
53
|
+
"@types/email-templates": "^10.0.4",
|
|
54
|
+
"@types/express": "^4.17.21",
|
|
55
|
+
"@types/jest": "^29.5.8",
|
|
56
|
+
"@types/jsonwebtoken": "^9.0.5",
|
|
57
|
+
"@types/locutus": "^0.0.8",
|
|
58
|
+
"@types/lodash": "^4.14.201",
|
|
59
|
+
"@types/qrcode": "^1.5.5",
|
|
60
|
+
"jest": "^29.7.0",
|
|
61
|
+
"ts-jest": "^29.1.1",
|
|
62
|
+
"typescript": "^5.2.2"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "228f0d25911d1b98859f2acf8ace3d3f251c4882"
|
|
65
65
|
}
|
package/src/AbleObject.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { Entity } from '@nymphjs/nymph';
|
|
|
6
6
|
* Used in entities which support abilities, such as users and groups.
|
|
7
7
|
*/
|
|
8
8
|
export default abstract class AbleObject<
|
|
9
|
-
T extends { abilities?: string[] }
|
|
9
|
+
T extends { abilities?: string[] },
|
|
10
10
|
> extends Entity<T> {
|
|
11
11
|
/**
|
|
12
12
|
* Grant an ability.
|
package/src/Group.test.ts
CHANGED
package/src/Group.ts
CHANGED
|
@@ -119,7 +119,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
static async factoryGroupname(
|
|
122
|
-
groupname?: string
|
|
122
|
+
groupname?: string,
|
|
123
123
|
): Promise<Group & GroupData> {
|
|
124
124
|
const entity = new this();
|
|
125
125
|
if (groupname != null) {
|
|
@@ -130,7 +130,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
130
130
|
{
|
|
131
131
|
type: '&',
|
|
132
132
|
ilike: ['groupname', groupname.replace(/([\\%_])/g, (s) => `\\${s}`)],
|
|
133
|
-
}
|
|
133
|
+
},
|
|
134
134
|
);
|
|
135
135
|
if (entity != null) {
|
|
136
136
|
return entity;
|
|
@@ -161,7 +161,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
161
161
|
*/
|
|
162
162
|
public static async getPrimaryGroups(
|
|
163
163
|
options?: Options,
|
|
164
|
-
selectors?: Selector[]
|
|
164
|
+
selectors?: Selector[],
|
|
165
165
|
) {
|
|
166
166
|
const tilmeld = enforceTilmeld(this);
|
|
167
167
|
if (!tilmeld.gatekeeper('tilmeld/admin')) {
|
|
@@ -171,7 +171,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
171
171
|
return await this.getAssignableGroups(
|
|
172
172
|
tilmeld.config.highestPrimary,
|
|
173
173
|
{ ...options, class: tilmeld.Group, return: 'entity' },
|
|
174
|
-
[...(selectors ?? [])]
|
|
174
|
+
[...(selectors ?? [])],
|
|
175
175
|
);
|
|
176
176
|
}
|
|
177
177
|
|
|
@@ -184,7 +184,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
184
184
|
*/
|
|
185
185
|
public static async getSecondaryGroups(
|
|
186
186
|
options?: Options,
|
|
187
|
-
selectors?: Selector[]
|
|
187
|
+
selectors?: Selector[],
|
|
188
188
|
) {
|
|
189
189
|
const tilmeld = enforceTilmeld(this);
|
|
190
190
|
if (!tilmeld.gatekeeper('tilmeld/admin')) {
|
|
@@ -194,14 +194,14 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
194
194
|
return await this.getAssignableGroups(
|
|
195
195
|
tilmeld.config.highestSecondary,
|
|
196
196
|
{ ...options, class: tilmeld.Group, return: 'entity' },
|
|
197
|
-
[...(selectors ?? [])]
|
|
197
|
+
[...(selectors ?? [])],
|
|
198
198
|
);
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
private static async getAssignableGroups(
|
|
202
202
|
highestParent: string | boolean,
|
|
203
203
|
options: Options<typeof Group>,
|
|
204
|
-
selectors: Selector[]
|
|
204
|
+
selectors: Selector[],
|
|
205
205
|
) {
|
|
206
206
|
const tilmeld = enforceTilmeld(this);
|
|
207
207
|
let assignableGroups: (Group & GroupData)[] = [];
|
|
@@ -212,7 +212,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
212
212
|
|
|
213
213
|
assignableGroups = await this.nymph.getEntities(
|
|
214
214
|
{ ...options, class: tilmeld.Group },
|
|
215
|
-
...selectors
|
|
215
|
+
...selectors,
|
|
216
216
|
);
|
|
217
217
|
if (highestParent !== true) {
|
|
218
218
|
assignableGroups = (
|
|
@@ -230,7 +230,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
230
230
|
await parent?.$wake();
|
|
231
231
|
}
|
|
232
232
|
return null;
|
|
233
|
-
})
|
|
233
|
+
}),
|
|
234
234
|
)
|
|
235
235
|
).filter((group) => group != null) as (Group & GroupData)[];
|
|
236
236
|
}
|
|
@@ -263,7 +263,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
263
263
|
!tilmeld.currentUser.abilities?.includes('system/admin'))
|
|
264
264
|
) {
|
|
265
265
|
throw new BadDataError(
|
|
266
|
-
"You don't have the authority to grant or revoke system/admin."
|
|
266
|
+
"You don't have the authority to grant or revoke system/admin.",
|
|
267
267
|
);
|
|
268
268
|
}
|
|
269
269
|
|
|
@@ -275,7 +275,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
275
275
|
!tilmeld.currentUser.abilities?.includes('system/admin'))
|
|
276
276
|
) {
|
|
277
277
|
throw new BadDataError(
|
|
278
|
-
"You don't have the authority to grant or revoke tilmeld/admin."
|
|
278
|
+
"You don't have the authority to grant or revoke tilmeld/admin.",
|
|
279
279
|
);
|
|
280
280
|
}
|
|
281
281
|
|
|
@@ -287,7 +287,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
287
287
|
!tilmeld.currentUser.abilities?.includes('system/admin'))
|
|
288
288
|
) {
|
|
289
289
|
throw new BadDataError(
|
|
290
|
-
"You don't have the authority to grant or revoke tilmeld/switch."
|
|
290
|
+
"You don't have the authority to grant or revoke tilmeld/switch.",
|
|
291
291
|
);
|
|
292
292
|
}
|
|
293
293
|
|
|
@@ -306,7 +306,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
306
306
|
!tilmeld.currentUser.abilities?.includes('system/admin'))
|
|
307
307
|
) {
|
|
308
308
|
throw new BadDataError(
|
|
309
|
-
"You don't have the authority to grant or revoke system/admin."
|
|
309
|
+
"You don't have the authority to grant or revoke system/admin.",
|
|
310
310
|
);
|
|
311
311
|
}
|
|
312
312
|
|
|
@@ -318,7 +318,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
318
318
|
!tilmeld.currentUser.abilities?.includes('system/admin'))
|
|
319
319
|
) {
|
|
320
320
|
throw new BadDataError(
|
|
321
|
-
"You don't have the authority to grant or revoke tilmeld/admin."
|
|
321
|
+
"You don't have the authority to grant or revoke tilmeld/admin.",
|
|
322
322
|
);
|
|
323
323
|
}
|
|
324
324
|
|
|
@@ -330,7 +330,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
330
330
|
!tilmeld.currentUser.abilities?.includes('system/admin'))
|
|
331
331
|
) {
|
|
332
332
|
throw new BadDataError(
|
|
333
|
-
"You don't have the authority to grant or revoke tilmeld/switch."
|
|
333
|
+
"You don't have the authority to grant or revoke tilmeld/switch.",
|
|
334
334
|
);
|
|
335
335
|
}
|
|
336
336
|
|
|
@@ -383,7 +383,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
383
383
|
* @returns True or false.
|
|
384
384
|
*/
|
|
385
385
|
public async $isDescendant(
|
|
386
|
-
givenGroup: (Group & GroupData) | string
|
|
386
|
+
givenGroup: (Group & GroupData) | string,
|
|
387
387
|
): Promise<boolean> {
|
|
388
388
|
const tilmeld = enforceTilmeld(this);
|
|
389
389
|
let group: Group & GroupData;
|
|
@@ -423,7 +423,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
423
423
|
type: '&',
|
|
424
424
|
equal: ['enabled', true],
|
|
425
425
|
ref: ['parent', this],
|
|
426
|
-
}
|
|
426
|
+
},
|
|
427
427
|
);
|
|
428
428
|
}
|
|
429
429
|
|
|
@@ -434,7 +434,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
434
434
|
* @returns An array of groups.
|
|
435
435
|
*/
|
|
436
436
|
public async $getDescendants(
|
|
437
|
-
andSelf = false
|
|
437
|
+
andSelf = false,
|
|
438
438
|
): Promise<(Group & GroupData)[]> {
|
|
439
439
|
const tilmeld = enforceTilmeld(this);
|
|
440
440
|
let groups: (Group & GroupData)[] = [];
|
|
@@ -444,7 +444,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
444
444
|
type: '&',
|
|
445
445
|
equal: ['enabled', true],
|
|
446
446
|
ref: ['parent', this],
|
|
447
|
-
}
|
|
447
|
+
},
|
|
448
448
|
);
|
|
449
449
|
for (let entity of entities) {
|
|
450
450
|
groups = (await entity.$getDescendants(true)).concat(groups);
|
|
@@ -492,7 +492,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
492
492
|
public async $getUsers(
|
|
493
493
|
descendants = false,
|
|
494
494
|
limit?: number,
|
|
495
|
-
offset?: number
|
|
495
|
+
offset?: number,
|
|
496
496
|
): Promise<(User & UserData)[]> {
|
|
497
497
|
const tilmeld = enforceTilmeld(this);
|
|
498
498
|
let groups: (Group & GroupData)[] = [];
|
|
@@ -523,7 +523,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
523
523
|
group,
|
|
524
524
|
]),
|
|
525
525
|
],
|
|
526
|
-
}
|
|
526
|
+
},
|
|
527
527
|
);
|
|
528
528
|
}
|
|
529
529
|
|
|
@@ -562,7 +562,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
562
562
|
if (
|
|
563
563
|
difference(
|
|
564
564
|
this.$data.groupname.split(''),
|
|
565
|
-
tilmeld.config.validChars.split('')
|
|
565
|
+
tilmeld.config.validChars.split(''),
|
|
566
566
|
).length
|
|
567
567
|
) {
|
|
568
568
|
return {
|
|
@@ -589,7 +589,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
589
589
|
}
|
|
590
590
|
const test = await this.$nymph.getEntity(
|
|
591
591
|
{ class: tilmeld.Group, skipAc: true },
|
|
592
|
-
selector
|
|
592
|
+
selector,
|
|
593
593
|
);
|
|
594
594
|
if (test != null) {
|
|
595
595
|
return { result: false, message: 'That groupname is taken.' };
|
|
@@ -656,7 +656,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
656
656
|
}
|
|
657
657
|
const test = await this.$nymph.getEntity(
|
|
658
658
|
{ class: tilmeld.Group, skipAc: true },
|
|
659
|
-
selector
|
|
659
|
+
selector,
|
|
660
660
|
);
|
|
661
661
|
if (test != null) {
|
|
662
662
|
return {
|
|
@@ -749,7 +749,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
749
749
|
(await parent.$isDescendant(this)))
|
|
750
750
|
) {
|
|
751
751
|
throw new BadDataError(
|
|
752
|
-
"Group parent can't be itself or descendant of itself."
|
|
752
|
+
"Group parent can't be itself or descendant of itself.",
|
|
753
753
|
);
|
|
754
754
|
}
|
|
755
755
|
|
|
@@ -763,14 +763,14 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
763
763
|
if (this.$data.defaultPrimary) {
|
|
764
764
|
const currentPrimary = await this.$nymph.getEntity(
|
|
765
765
|
{ class: tilmeld.Group },
|
|
766
|
-
{ type: '&', truthy: 'defaultPrimary' }
|
|
766
|
+
{ type: '&', truthy: 'defaultPrimary' },
|
|
767
767
|
);
|
|
768
768
|
if (currentPrimary != null && !this.$is(currentPrimary)) {
|
|
769
769
|
currentPrimary.defaultPrimary = false;
|
|
770
770
|
if (!(await currentPrimary.$save())) {
|
|
771
771
|
throw new CouldNotChangeDefaultPrimaryGroupError(
|
|
772
772
|
'Could not change new user primary group from ' +
|
|
773
|
-
`${currentPrimary.groupname}
|
|
773
|
+
`${currentPrimary.groupname}.`,
|
|
774
774
|
);
|
|
775
775
|
}
|
|
776
776
|
}
|
|
@@ -828,7 +828,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
828
828
|
{
|
|
829
829
|
type: '&',
|
|
830
830
|
ref: ['group', this],
|
|
831
|
-
}
|
|
831
|
+
},
|
|
832
832
|
);
|
|
833
833
|
for (let user of primaryUsers) {
|
|
834
834
|
delete user.group;
|
|
@@ -848,7 +848,7 @@ export default class Group extends AbleObject<GroupData> {
|
|
|
848
848
|
{
|
|
849
849
|
type: '&',
|
|
850
850
|
ref: ['groups', this],
|
|
851
|
-
}
|
|
851
|
+
},
|
|
852
852
|
);
|
|
853
853
|
for (let user of secondaryUsers) {
|
|
854
854
|
user.$delGroup(this);
|
package/src/Tilmeld.ts
CHANGED
|
@@ -183,7 +183,7 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
183
183
|
const handleQuery = function (
|
|
184
184
|
nymph: Nymph,
|
|
185
185
|
options: Options,
|
|
186
|
-
selectors: FormattedSelector[]
|
|
186
|
+
selectors: FormattedSelector[],
|
|
187
187
|
) {
|
|
188
188
|
const tilmeld = enforceTilmeld(nymph);
|
|
189
189
|
if (
|
|
@@ -225,7 +225,7 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
225
225
|
// Filter entities being deleted for user permissions.
|
|
226
226
|
const checkPermissionsDelete = async function (
|
|
227
227
|
nymph: Nymph,
|
|
228
|
-
entity: EntityInterface
|
|
228
|
+
entity: EntityInterface,
|
|
229
229
|
) {
|
|
230
230
|
const tilmeld = enforceTilmeld(nymph);
|
|
231
231
|
if (
|
|
@@ -245,11 +245,11 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
245
245
|
const checkPermissionsDeleteByID = async function (
|
|
246
246
|
nymph: Nymph,
|
|
247
247
|
guid: string,
|
|
248
|
-
className?: string
|
|
248
|
+
className?: string,
|
|
249
249
|
) {
|
|
250
250
|
const entity = await nymph.getEntity(
|
|
251
251
|
{ class: nymph.getEntityClass(className ?? 'Entity') },
|
|
252
|
-
{ type: '&', guid: guid }
|
|
252
|
+
{ type: '&', guid: guid },
|
|
253
253
|
);
|
|
254
254
|
if (entity != null) {
|
|
255
255
|
checkPermissionsDelete(nymph, entity);
|
|
@@ -261,7 +261,7 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
261
261
|
// disallowed changes to AC properties.
|
|
262
262
|
const checkPermissionsSaveAndFilterAcChanges = async function (
|
|
263
263
|
nymph: Nymph,
|
|
264
|
-
entity: EntityInterface & AccessControlData
|
|
264
|
+
entity: EntityInterface & AccessControlData,
|
|
265
265
|
) {
|
|
266
266
|
const tilmeld = enforceTilmeld(nymph);
|
|
267
267
|
if (!entity) {
|
|
@@ -338,12 +338,12 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
338
338
|
entity,
|
|
339
339
|
TilmeldAccessLevels.FULL_ACCESS,
|
|
340
340
|
undefined,
|
|
341
|
-
originalAc
|
|
341
|
+
originalAc,
|
|
342
342
|
)
|
|
343
343
|
) {
|
|
344
344
|
// Only allow changes to AC properties if the user has full access.
|
|
345
345
|
throw new AccessControlError(
|
|
346
|
-
'No permission to change access control properties.'
|
|
346
|
+
'No permission to change access control properties.',
|
|
347
347
|
);
|
|
348
348
|
}
|
|
349
349
|
|
|
@@ -354,7 +354,7 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
354
354
|
newAc.user !== tilmeld.currentUser)
|
|
355
355
|
) {
|
|
356
356
|
throw new AccessControlError(
|
|
357
|
-
'No permission to assign to another user.'
|
|
357
|
+
'No permission to assign to another user.',
|
|
358
358
|
);
|
|
359
359
|
}
|
|
360
360
|
|
|
@@ -366,7 +366,7 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
366
366
|
(tilmeld.currentUser?.$getGids() ?? []).includes(newAc.group))
|
|
367
367
|
) {
|
|
368
368
|
throw new AccessControlError(
|
|
369
|
-
'No permission to assign to another group.'
|
|
369
|
+
'No permission to assign to another group.',
|
|
370
370
|
);
|
|
371
371
|
}
|
|
372
372
|
}
|
|
@@ -397,7 +397,7 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
397
397
|
*/
|
|
398
398
|
const addAccess = async function (
|
|
399
399
|
nymph: Nymph,
|
|
400
|
-
entity: EntityInterface & AccessControlData
|
|
400
|
+
entity: EntityInterface & AccessControlData,
|
|
401
401
|
) {
|
|
402
402
|
const tilmeld = enforceTilmeld(nymph);
|
|
403
403
|
const user = tilmeld.currentUser;
|
|
@@ -440,7 +440,7 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
440
440
|
|
|
441
441
|
const validate = async function (
|
|
442
442
|
_nymph: Nymph,
|
|
443
|
-
entity: EntityInterface & AccessControlData
|
|
443
|
+
entity: EntityInterface & AccessControlData,
|
|
444
444
|
) {
|
|
445
445
|
if (!(entity instanceof User) && !(entity instanceof Group)) {
|
|
446
446
|
const ownershipAcPropertyValidator = (prop: any) => {
|
|
@@ -450,7 +450,7 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
450
450
|
prop > TilmeldAccessLevels.FULL_ACCESS
|
|
451
451
|
) {
|
|
452
452
|
throw new AccessControlError(
|
|
453
|
-
'Invalid access control property: ' + prop
|
|
453
|
+
'Invalid access control property: ' + prop,
|
|
454
454
|
);
|
|
455
455
|
}
|
|
456
456
|
};
|
|
@@ -458,13 +458,13 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
458
458
|
const accessAcPropertyValidator = (prop: any) => {
|
|
459
459
|
if (!Array.isArray(prop)) {
|
|
460
460
|
throw new AccessControlError(
|
|
461
|
-
'Invalid access control property: ' + prop
|
|
461
|
+
'Invalid access control property: ' + prop,
|
|
462
462
|
);
|
|
463
463
|
}
|
|
464
464
|
prop.forEach((value) => {
|
|
465
465
|
if (!(value instanceof User || value instanceof Group)) {
|
|
466
466
|
throw new AccessControlError(
|
|
467
|
-
'Invalid access control property: ' + prop
|
|
467
|
+
'Invalid access control property: ' + prop,
|
|
468
468
|
);
|
|
469
469
|
}
|
|
470
470
|
});
|
|
@@ -473,7 +473,7 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
473
473
|
if ('user' in entity) {
|
|
474
474
|
if (!(entity.user instanceof User)) {
|
|
475
475
|
throw new AccessControlError(
|
|
476
|
-
'Invalid access control property: user'
|
|
476
|
+
'Invalid access control property: user',
|
|
477
477
|
);
|
|
478
478
|
}
|
|
479
479
|
}
|
|
@@ -481,7 +481,7 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
481
481
|
if ('group' in entity) {
|
|
482
482
|
if (!(entity.group instanceof Group)) {
|
|
483
483
|
throw new AccessControlError(
|
|
484
|
-
'Invalid access control property: group'
|
|
484
|
+
'Invalid access control property: group',
|
|
485
485
|
);
|
|
486
486
|
}
|
|
487
487
|
}
|
|
@@ -526,7 +526,7 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
526
526
|
*/
|
|
527
527
|
public addAccessControlSelectors(
|
|
528
528
|
options: Options,
|
|
529
|
-
selectors: FormattedSelector[]
|
|
529
|
+
selectors: FormattedSelector[],
|
|
530
530
|
) {
|
|
531
531
|
const user = this.currentUser;
|
|
532
532
|
|
|
@@ -691,7 +691,7 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
691
691
|
entity: EntityInterface,
|
|
692
692
|
type: TilmeldAccessLevels = TilmeldAccessLevels.READ_ACCESS,
|
|
693
693
|
user?: (User & UserData) | false,
|
|
694
|
-
acProperties?: ACProperties
|
|
694
|
+
acProperties?: ACProperties,
|
|
695
695
|
) {
|
|
696
696
|
if (!acProperties) {
|
|
697
697
|
acProperties = entity.$getCurrentAcValues() as ACProperties;
|
|
@@ -811,7 +811,7 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
811
811
|
public async checkClientUIDPermissions(
|
|
812
812
|
name: string,
|
|
813
813
|
type: TilmeldAccessLevels = TilmeldAccessLevels.READ_ACCESS,
|
|
814
|
-
user?: (User & UserData) | false
|
|
814
|
+
user?: (User & UserData) | false,
|
|
815
815
|
) {
|
|
816
816
|
let userOrEmpty: User & UserData = this.User.factorySync();
|
|
817
817
|
// Calculate the user.
|
|
@@ -896,7 +896,7 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
896
896
|
{
|
|
897
897
|
type: '&',
|
|
898
898
|
guid: guid,
|
|
899
|
-
}
|
|
899
|
+
},
|
|
900
900
|
);
|
|
901
901
|
if (!user || !user.guid) {
|
|
902
902
|
return null;
|
|
@@ -1050,7 +1050,7 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
1050
1050
|
public async login(
|
|
1051
1051
|
user: User & UserData,
|
|
1052
1052
|
sendAuthHeader: boolean,
|
|
1053
|
-
sendCookie = true
|
|
1053
|
+
sendCookie = true,
|
|
1054
1054
|
) {
|
|
1055
1055
|
if (user.guid != null && user.enabled) {
|
|
1056
1056
|
if (this.response) {
|
|
@@ -1096,7 +1096,7 @@ export default class Tilmeld implements TilmeldInterface {
|
|
|
1096
1096
|
public async loginSwitch(
|
|
1097
1097
|
user: User & UserData,
|
|
1098
1098
|
sendAuthHeader: boolean,
|
|
1099
|
-
sendCookie = true
|
|
1099
|
+
sendCookie = true,
|
|
1100
1100
|
) {
|
|
1101
1101
|
if (user.guid != null) {
|
|
1102
1102
|
if (this.response) {
|
package/src/User.test.ts
CHANGED
package/src/User.ts
CHANGED
|
@@ -40,7 +40,7 @@ export type EventType =
|
|
|
40
40
|
*/
|
|
41
41
|
export type TilmeldCheckUsernameCallback = (
|
|
42
42
|
user: User & UserData,
|
|
43
|
-
data: { username: string }
|
|
43
|
+
data: { username: string },
|
|
44
44
|
) => Promise<{ result: boolean; message?: string }>;
|
|
45
45
|
/**
|
|
46
46
|
* Theses are run before the user data checks, so the only checks before are
|
|
@@ -48,11 +48,11 @@ export type TilmeldCheckUsernameCallback = (
|
|
|
48
48
|
*/
|
|
49
49
|
export type TilmeldBeforeRegisterCallback = (
|
|
50
50
|
user: User & UserData,
|
|
51
|
-
data: { password: string; additionalData?: { [k: string]: any } }
|
|
51
|
+
data: { password: string; additionalData?: { [k: string]: any } },
|
|
52
52
|
) => Promise<void>;
|
|
53
53
|
export type TilmeldAfterRegisterCallback = (
|
|
54
54
|
user: User & UserData,
|
|
55
|
-
result: { loggedin: boolean; message: string }
|
|
55
|
+
result: { loggedin: boolean; message: string },
|
|
56
56
|
) => Promise<void>;
|
|
57
57
|
/**
|
|
58
58
|
* These are run after the authentication checks, but before the login action.
|
|
@@ -63,20 +63,20 @@ export type TilmeldBeforeLoginCallback = (
|
|
|
63
63
|
username: string;
|
|
64
64
|
password: string;
|
|
65
65
|
additionalData?: { [k: string]: any };
|
|
66
|
-
}
|
|
66
|
+
},
|
|
67
67
|
) => Promise<void>;
|
|
68
68
|
/**
|
|
69
69
|
* This is run before the transaction is committed, and you can perform
|
|
70
70
|
* additional functions on the transaction, which is available in `user.$nymph`.
|
|
71
71
|
*/
|
|
72
72
|
export type TilmeldAfterLoginCallback = (
|
|
73
|
-
user: User & UserData
|
|
73
|
+
user: User & UserData,
|
|
74
74
|
) => Promise<void>;
|
|
75
75
|
export type TilmeldBeforeLogoutCallback = (
|
|
76
|
-
user: User & UserData
|
|
76
|
+
user: User & UserData,
|
|
77
77
|
) => Promise<void>;
|
|
78
78
|
export type TilmeldAfterLogoutCallback = (
|
|
79
|
-
user: User & UserData
|
|
79
|
+
user: User & UserData,
|
|
80
80
|
) => Promise<void>;
|
|
81
81
|
|
|
82
82
|
export type UserData = {
|
|
@@ -303,7 +303,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
303
303
|
{
|
|
304
304
|
type: '&',
|
|
305
305
|
ilike: ['username', username.replace(/([\\%_])/g, (s) => `\\${s}`)],
|
|
306
|
-
}
|
|
306
|
+
},
|
|
307
307
|
);
|
|
308
308
|
if (entity != null) {
|
|
309
309
|
return entity;
|
|
@@ -329,10 +329,10 @@ export default class User extends AbleObject<UserData> {
|
|
|
329
329
|
|
|
330
330
|
public static current(returnObjectIfNotExist: true): User & UserData;
|
|
331
331
|
public static current(
|
|
332
|
-
returnObjectIfNotExist?: false
|
|
332
|
+
returnObjectIfNotExist?: false,
|
|
333
333
|
): (User & UserData) | null;
|
|
334
334
|
public static current(
|
|
335
|
-
returnObjectIfNotExist?: boolean
|
|
335
|
+
returnObjectIfNotExist?: boolean,
|
|
336
336
|
): (User & UserData) | null {
|
|
337
337
|
const tilmeld = enforceTilmeld(this);
|
|
338
338
|
if (tilmeld.currentUser == null) {
|
|
@@ -370,7 +370,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
370
370
|
{
|
|
371
371
|
type: '&',
|
|
372
372
|
ilike: ['email', data.account.replace(/([\\%_])/g, (s) => `\\${s}`)],
|
|
373
|
-
}
|
|
373
|
+
},
|
|
374
374
|
);
|
|
375
375
|
|
|
376
376
|
if (getUser == null) {
|
|
@@ -466,7 +466,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
466
466
|
data.secret !== user.recoverSecret ||
|
|
467
467
|
strtotime(
|
|
468
468
|
'+' + tilmeld.config.pwRecoveryTimeLimit,
|
|
469
|
-
Math.floor((user.recoverSecretDate ?? 0) / 1000)
|
|
469
|
+
Math.floor((user.recoverSecretDate ?? 0) / 1000),
|
|
470
470
|
) *
|
|
471
471
|
1000 <
|
|
472
472
|
Date.now()
|
|
@@ -745,7 +745,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
745
745
|
await Promise.all(this.$data.groups?.map((e) => e.$wake()) || []);
|
|
746
746
|
for (let curGroup of this.$data.groups ?? []) {
|
|
747
747
|
this.$descendantGroups = this.$descendantGroups?.concat(
|
|
748
|
-
await curGroup.$getDescendants()
|
|
748
|
+
await curGroup.$getDescendants(),
|
|
749
749
|
);
|
|
750
750
|
}
|
|
751
751
|
}
|
|
@@ -764,7 +764,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
764
764
|
!tilmeld.currentUser.abilities?.includes('system/admin'))
|
|
765
765
|
) {
|
|
766
766
|
throw new BadDataError(
|
|
767
|
-
"You don't have the authority to grant or revoke system/admin."
|
|
767
|
+
"You don't have the authority to grant or revoke system/admin.",
|
|
768
768
|
);
|
|
769
769
|
}
|
|
770
770
|
|
|
@@ -776,7 +776,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
776
776
|
!tilmeld.currentUser.abilities?.includes('system/admin'))
|
|
777
777
|
) {
|
|
778
778
|
throw new BadDataError(
|
|
779
|
-
"You don't have the authority to grant or revoke tilmeld/admin."
|
|
779
|
+
"You don't have the authority to grant or revoke tilmeld/admin.",
|
|
780
780
|
);
|
|
781
781
|
}
|
|
782
782
|
|
|
@@ -788,7 +788,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
788
788
|
!tilmeld.currentUser.abilities?.includes('system/admin'))
|
|
789
789
|
) {
|
|
790
790
|
throw new BadDataError(
|
|
791
|
-
"You don't have the authority to grant or revoke tilmeld/switch."
|
|
791
|
+
"You don't have the authority to grant or revoke tilmeld/switch.",
|
|
792
792
|
);
|
|
793
793
|
}
|
|
794
794
|
|
|
@@ -808,7 +808,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
808
808
|
!tilmeld.currentUser.abilities?.includes('system/admin'))
|
|
809
809
|
) {
|
|
810
810
|
throw new BadDataError(
|
|
811
|
-
"You don't have the authority to grant or revoke system/admin."
|
|
811
|
+
"You don't have the authority to grant or revoke system/admin.",
|
|
812
812
|
);
|
|
813
813
|
}
|
|
814
814
|
|
|
@@ -820,7 +820,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
820
820
|
!tilmeld.currentUser.abilities?.includes('system/admin'))
|
|
821
821
|
) {
|
|
822
822
|
throw new BadDataError(
|
|
823
|
-
"You don't have the authority to grant or revoke tilmeld/admin."
|
|
823
|
+
"You don't have the authority to grant or revoke tilmeld/admin.",
|
|
824
824
|
);
|
|
825
825
|
}
|
|
826
826
|
|
|
@@ -832,7 +832,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
832
832
|
!tilmeld.currentUser.abilities?.includes('system/admin'))
|
|
833
833
|
) {
|
|
834
834
|
throw new BadDataError(
|
|
835
|
-
"You don't have the authority to grant or revoke tilmeld/switch."
|
|
835
|
+
"You don't have the authority to grant or revoke tilmeld/switch.",
|
|
836
836
|
);
|
|
837
837
|
}
|
|
838
838
|
|
|
@@ -1015,7 +1015,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
1015
1015
|
}
|
|
1016
1016
|
}
|
|
1017
1017
|
return Object.fromEntries(
|
|
1018
|
-
abilities.map((ability) => [ability, true as true])
|
|
1018
|
+
abilities.map((ability) => [ability, true as true]),
|
|
1019
1019
|
);
|
|
1020
1020
|
}
|
|
1021
1021
|
|
|
@@ -1044,7 +1044,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
1044
1044
|
|
|
1045
1045
|
if (this.$data.secret != null) {
|
|
1046
1046
|
const link = `${verifyUrl}?action=verify&id=${encodeURIComponent(
|
|
1047
|
-
this.guid
|
|
1047
|
+
this.guid,
|
|
1048
1048
|
)}&secret=${encodeURIComponent(this.$data.secret)}`;
|
|
1049
1049
|
success =
|
|
1050
1050
|
success &&
|
|
@@ -1062,13 +1062,13 @@ export default class User extends AbleObject<UserData> {
|
|
|
1062
1062
|
verifyLink: link,
|
|
1063
1063
|
},
|
|
1064
1064
|
},
|
|
1065
|
-
this
|
|
1065
|
+
this,
|
|
1066
1066
|
));
|
|
1067
1067
|
}
|
|
1068
1068
|
|
|
1069
1069
|
if (this.$data.newEmailSecret != null) {
|
|
1070
1070
|
const link = `${verifyUrl}?action=verifychange&id=${encodeURIComponent(
|
|
1071
|
-
this.guid
|
|
1071
|
+
this.guid,
|
|
1072
1072
|
)}&secret=${encodeURIComponent(this.$data.newEmailSecret)}`;
|
|
1073
1073
|
success =
|
|
1074
1074
|
success &&
|
|
@@ -1088,13 +1088,13 @@ export default class User extends AbleObject<UserData> {
|
|
|
1088
1088
|
newEmail: this.$data.newEmailAddress,
|
|
1089
1089
|
},
|
|
1090
1090
|
},
|
|
1091
|
-
this
|
|
1091
|
+
this,
|
|
1092
1092
|
));
|
|
1093
1093
|
}
|
|
1094
1094
|
|
|
1095
1095
|
if (this.$data.cancelEmailSecret != null) {
|
|
1096
1096
|
const link = `${verifyUrl}?action=cancelchange&id=${encodeURIComponent(
|
|
1097
|
-
this.guid
|
|
1097
|
+
this.guid,
|
|
1098
1098
|
)}&secret=${encodeURIComponent(this.$data.cancelEmailSecret)}`;
|
|
1099
1099
|
success =
|
|
1100
1100
|
success &&
|
|
@@ -1114,7 +1114,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
1114
1114
|
newEmail: this.$data.newEmailAddress ?? this.$data.email,
|
|
1115
1115
|
},
|
|
1116
1116
|
},
|
|
1117
|
-
this
|
|
1117
|
+
this,
|
|
1118
1118
|
));
|
|
1119
1119
|
}
|
|
1120
1120
|
|
|
@@ -1286,7 +1286,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
1286
1286
|
default:
|
|
1287
1287
|
this.$data.salt = nanoid();
|
|
1288
1288
|
this.$data.password = sha256(password + this.$data.salt).toString(
|
|
1289
|
-
Base64
|
|
1289
|
+
Base64,
|
|
1290
1290
|
);
|
|
1291
1291
|
break;
|
|
1292
1292
|
}
|
|
@@ -1536,7 +1536,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
1536
1536
|
if (
|
|
1537
1537
|
difference(
|
|
1538
1538
|
this.$data.username.split(''),
|
|
1539
|
-
tilmeld.config.validChars.split('')
|
|
1539
|
+
tilmeld.config.validChars.split(''),
|
|
1540
1540
|
).length
|
|
1541
1541
|
) {
|
|
1542
1542
|
return {
|
|
@@ -1563,7 +1563,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
1563
1563
|
}
|
|
1564
1564
|
const test = await this.$nymph.getEntity(
|
|
1565
1565
|
{ class: tilmeld.User, skipAc: true },
|
|
1566
|
-
selector
|
|
1566
|
+
selector,
|
|
1567
1567
|
);
|
|
1568
1568
|
if (test != null) {
|
|
1569
1569
|
return { result: false, message: 'That username is taken.' };
|
|
@@ -1643,7 +1643,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
1643
1643
|
}
|
|
1644
1644
|
const test = await this.$nymph.getEntity(
|
|
1645
1645
|
{ class: tilmeld.User, skipAc: true },
|
|
1646
|
-
selector
|
|
1646
|
+
selector,
|
|
1647
1647
|
);
|
|
1648
1648
|
if (test != null) {
|
|
1649
1649
|
return {
|
|
@@ -1687,7 +1687,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
1687
1687
|
}
|
|
1688
1688
|
const test = await this.$nymph.getEntity(
|
|
1689
1689
|
{ class: tilmeld.User, skipAc: true },
|
|
1690
|
-
selector
|
|
1690
|
+
selector,
|
|
1691
1691
|
);
|
|
1692
1692
|
if (test != null) {
|
|
1693
1693
|
return { result: false, message: 'Phone number is in use.' };
|
|
@@ -1783,7 +1783,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
1783
1783
|
{
|
|
1784
1784
|
type: '&',
|
|
1785
1785
|
equal: ['defaultPrimary', true],
|
|
1786
|
-
}
|
|
1786
|
+
},
|
|
1787
1787
|
);
|
|
1788
1788
|
if (parent != null) {
|
|
1789
1789
|
generatedPrimaryGroup.parent = parent;
|
|
@@ -1805,7 +1805,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
1805
1805
|
{
|
|
1806
1806
|
type: '&',
|
|
1807
1807
|
equal: ['defaultPrimary', true],
|
|
1808
|
-
}
|
|
1808
|
+
},
|
|
1809
1809
|
);
|
|
1810
1810
|
if (group != null) {
|
|
1811
1811
|
this.$data.group = group;
|
|
@@ -1820,7 +1820,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
1820
1820
|
{
|
|
1821
1821
|
type: '&',
|
|
1822
1822
|
equal: ['unverifiedSecondary', true],
|
|
1823
|
-
}
|
|
1823
|
+
},
|
|
1824
1824
|
);
|
|
1825
1825
|
} else {
|
|
1826
1826
|
// Add the default secondaries.
|
|
@@ -1829,7 +1829,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
1829
1829
|
{
|
|
1830
1830
|
type: '&',
|
|
1831
1831
|
equal: ['defaultSecondary', true],
|
|
1832
|
-
}
|
|
1832
|
+
},
|
|
1833
1833
|
);
|
|
1834
1834
|
}
|
|
1835
1835
|
|
|
@@ -1879,7 +1879,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
1879
1879
|
userPhone: this.$data.phone,
|
|
1880
1880
|
},
|
|
1881
1881
|
},
|
|
1882
|
-
this
|
|
1882
|
+
this,
|
|
1883
1883
|
);
|
|
1884
1884
|
}
|
|
1885
1885
|
|
|
@@ -1982,7 +1982,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
1982
1982
|
this.$data.abilities?.includes('system/admin')
|
|
1983
1983
|
) {
|
|
1984
1984
|
throw new BadDataError(
|
|
1985
|
-
"You don't have the authority to modify system admins."
|
|
1985
|
+
"You don't have the authority to modify system admins.",
|
|
1986
1986
|
);
|
|
1987
1987
|
}
|
|
1988
1988
|
|
|
@@ -2100,10 +2100,10 @@ export default class User extends AbleObject<UserData> {
|
|
|
2100
2100
|
new Date(
|
|
2101
2101
|
strtotime(
|
|
2102
2102
|
'+' + tilmeld.config.emailRateLimit,
|
|
2103
|
-
Math.floor(this.$data.emailChangeDate / 1000)
|
|
2104
|
-
) * 1000
|
|
2103
|
+
Math.floor(this.$data.emailChangeDate / 1000),
|
|
2104
|
+
) * 1000,
|
|
2105
2105
|
).toString() +
|
|
2106
|
-
' to change your email address again.'
|
|
2106
|
+
' to change your email address again.',
|
|
2107
2107
|
);
|
|
2108
2108
|
} else {
|
|
2109
2109
|
if (
|
|
@@ -2258,7 +2258,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
2258
2258
|
this.$data.abilities?.includes('system/admin')
|
|
2259
2259
|
) {
|
|
2260
2260
|
throw new BadDataError(
|
|
2261
|
-
"You don't have the authority to delete system admins."
|
|
2261
|
+
"You don't have the authority to delete system admins.",
|
|
2262
2262
|
);
|
|
2263
2263
|
}
|
|
2264
2264
|
if (tilmeld.User.current(true).$is(this)) {
|
|
@@ -2283,7 +2283,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
2283
2283
|
? TilmeldBeforeLogoutCallback
|
|
2284
2284
|
: T extends 'afterLogout'
|
|
2285
2285
|
? TilmeldAfterLogoutCallback
|
|
2286
|
-
: never
|
|
2286
|
+
: never,
|
|
2287
2287
|
) {
|
|
2288
2288
|
const prop = (event + 'Callbacks') as T extends 'checkUsername'
|
|
2289
2289
|
? 'checkUsernameCallbacks'
|
|
@@ -2324,7 +2324,7 @@ export default class User extends AbleObject<UserData> {
|
|
|
2324
2324
|
? TilmeldBeforeLogoutCallback
|
|
2325
2325
|
: T extends 'afterLogout'
|
|
2326
2326
|
? TilmeldAfterLogoutCallback
|
|
2327
|
-
: never
|
|
2327
|
+
: never,
|
|
2328
2328
|
) {
|
|
2329
2329
|
const prop = (event + 'Callbacks') as T extends 'checkUsername'
|
|
2330
2330
|
? 'checkUsernameCallbacks'
|
package/src/conf/d.ts
CHANGED
|
@@ -237,7 +237,7 @@ export interface Config {
|
|
|
237
237
|
jwtBuilder: (
|
|
238
238
|
config: Config,
|
|
239
239
|
user: User & UserData,
|
|
240
|
-
switchToken?: boolean
|
|
240
|
+
switchToken?: boolean,
|
|
241
241
|
) => string;
|
|
242
242
|
/**
|
|
243
243
|
* Function to verify that a JWT was signed with the secret key, validate its
|
|
@@ -251,7 +251,7 @@ export interface Config {
|
|
|
251
251
|
jwtExtract: (
|
|
252
252
|
config: Config,
|
|
253
253
|
token: string,
|
|
254
|
-
xsrfToken?: string
|
|
254
|
+
xsrfToken?: string,
|
|
255
255
|
) => { guid: string; issued: Date; expire: Date } | null;
|
|
256
256
|
/**
|
|
257
257
|
* The absolute path to the email template directory. Used by the default
|
|
@@ -268,7 +268,7 @@ export interface Config {
|
|
|
268
268
|
configEmail: (
|
|
269
269
|
tilmeld: Tilmeld,
|
|
270
270
|
options: EmailOptions,
|
|
271
|
-
user: User & UserData
|
|
271
|
+
user: User & UserData,
|
|
272
272
|
) => Promise<EmailConfig>;
|
|
273
273
|
/**
|
|
274
274
|
* Send an email to a user. Uses `email-templates` by default.
|
|
@@ -298,7 +298,7 @@ export interface Config {
|
|
|
298
298
|
sendEmail: (
|
|
299
299
|
tilmeld: Tilmeld,
|
|
300
300
|
options: EmailOptions,
|
|
301
|
-
user: User & UserData
|
|
301
|
+
user: User & UserData,
|
|
302
302
|
) => Promise<boolean>;
|
|
303
303
|
/**
|
|
304
304
|
* The address you'd like to receive a notification of registered users, if
|
package/src/conf/defaults.ts
CHANGED
|
@@ -69,7 +69,7 @@ export default {
|
|
|
69
69
|
xsrfToken: 'TILMELDXSRF-' + nanoid(),
|
|
70
70
|
},
|
|
71
71
|
secret,
|
|
72
|
-
{ expiresIn: switchToken ? config.jwtSwitchExpire : config.jwtExpire }
|
|
72
|
+
{ expiresIn: switchToken ? config.jwtSwitchExpire : config.jwtExpire },
|
|
73
73
|
);
|
|
74
74
|
},
|
|
75
75
|
jwtExtract: (config, token, xsrfToken?) => {
|
|
@@ -129,14 +129,14 @@ export default {
|
|
|
129
129
|
},
|
|
130
130
|
sendEmail: async (tilmeld, options, user) => {
|
|
131
131
|
const email = new Email(
|
|
132
|
-
await tilmeld.config.configEmail(tilmeld, options, user)
|
|
132
|
+
await tilmeld.config.configEmail(tilmeld, options, user),
|
|
133
133
|
);
|
|
134
134
|
try {
|
|
135
135
|
const result = await email.send({
|
|
136
136
|
...options,
|
|
137
137
|
template: path.join(
|
|
138
138
|
tilmeld.config.emailTemplateDir,
|
|
139
|
-
options.template ?? '.'
|
|
139
|
+
options.template ?? '.',
|
|
140
140
|
),
|
|
141
141
|
locals: {
|
|
142
142
|
// System
|
|
@@ -206,13 +206,13 @@ export default {
|
|
|
206
206
|
name: 'control characters',
|
|
207
207
|
invert: true,
|
|
208
208
|
})
|
|
209
|
-
.max(256)
|
|
209
|
+
.max(256),
|
|
210
210
|
),
|
|
211
211
|
defaultPrimary: Joi.boolean(),
|
|
212
212
|
defaultSecondary: Joi.boolean(),
|
|
213
213
|
unverifiedSecondary: Joi.boolean(),
|
|
214
214
|
}),
|
|
215
|
-
'Invalid Group: '
|
|
215
|
+
'Invalid Group: ',
|
|
216
216
|
);
|
|
217
217
|
},
|
|
218
218
|
validatorUser: (user) => {
|
|
@@ -275,7 +275,7 @@ export default {
|
|
|
275
275
|
name: 'control characters',
|
|
276
276
|
invert: true,
|
|
277
277
|
})
|
|
278
|
-
.max(256)
|
|
278
|
+
.max(256),
|
|
279
279
|
),
|
|
280
280
|
inheritAbilities: Joi.boolean(),
|
|
281
281
|
secret: Joi.string()
|
|
@@ -323,7 +323,7 @@ export default {
|
|
|
323
323
|
.max(40)
|
|
324
324
|
.pattern(/^[A-Z234567]+$/, 'base32 encoded unpadded'),
|
|
325
325
|
}),
|
|
326
|
-
'Invalid User: '
|
|
326
|
+
'Invalid User: ',
|
|
327
327
|
);
|
|
328
328
|
},
|
|
329
329
|
} as Config;
|
package/src/tilmeldJoiProps.ts
CHANGED
|
@@ -11,36 +11,36 @@ export default {
|
|
|
11
11
|
TilmeldAccessLevels.NO_ACCESS,
|
|
12
12
|
TilmeldAccessLevels.READ_ACCESS,
|
|
13
13
|
TilmeldAccessLevels.WRITE_ACCESS,
|
|
14
|
-
TilmeldAccessLevels.FULL_ACCESS
|
|
14
|
+
TilmeldAccessLevels.FULL_ACCESS,
|
|
15
15
|
),
|
|
16
16
|
acGroup: Joi.number().valid(
|
|
17
17
|
TilmeldAccessLevels.NO_ACCESS,
|
|
18
18
|
TilmeldAccessLevels.READ_ACCESS,
|
|
19
19
|
TilmeldAccessLevels.WRITE_ACCESS,
|
|
20
|
-
TilmeldAccessLevels.FULL_ACCESS
|
|
20
|
+
TilmeldAccessLevels.FULL_ACCESS,
|
|
21
21
|
),
|
|
22
22
|
acOther: Joi.number().valid(
|
|
23
23
|
TilmeldAccessLevels.NO_ACCESS,
|
|
24
24
|
TilmeldAccessLevels.READ_ACCESS,
|
|
25
25
|
TilmeldAccessLevels.WRITE_ACCESS,
|
|
26
|
-
TilmeldAccessLevels.FULL_ACCESS
|
|
26
|
+
TilmeldAccessLevels.FULL_ACCESS,
|
|
27
27
|
),
|
|
28
28
|
acRead: Joi.array().items(
|
|
29
29
|
Joi.alternatives().try(
|
|
30
30
|
Joi.object().instance(User),
|
|
31
|
-
Joi.object().instance(Group)
|
|
32
|
-
)
|
|
31
|
+
Joi.object().instance(Group),
|
|
32
|
+
),
|
|
33
33
|
),
|
|
34
34
|
acWrite: Joi.array().items(
|
|
35
35
|
Joi.alternatives().try(
|
|
36
36
|
Joi.object().instance(User),
|
|
37
|
-
Joi.object().instance(Group)
|
|
38
|
-
)
|
|
37
|
+
Joi.object().instance(Group),
|
|
38
|
+
),
|
|
39
39
|
),
|
|
40
40
|
acFull: Joi.array().items(
|
|
41
41
|
Joi.alternatives().try(
|
|
42
42
|
Joi.object().instance(User),
|
|
43
|
-
Joi.object().instance(Group)
|
|
44
|
-
)
|
|
43
|
+
Joi.object().instance(Group),
|
|
44
|
+
),
|
|
45
45
|
),
|
|
46
46
|
};
|