@stamhoofd/backend 2.82.0 → 2.83.0
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/package.json +10 -10
- package/src/audit-logs/GroupLogger.ts +3 -3
- package/src/audit-logs/MemberResponsibilityRecordLogger.ts +1 -1
- package/src/audit-logs/OrderLogger.ts +1 -1
- package/src/audit-logs/RegistrationLogger.ts +1 -1
- package/src/endpoints/admin/members/ChargeMembersEndpoint.ts +4 -4
- package/src/endpoints/admin/memberships/ChargeMembershipsEndpoint.ts +1 -1
- package/src/endpoints/admin/organizations/ChargeOrganizationsEndpoint.ts +5 -5
- package/src/endpoints/admin/organizations/GetOrganizationsEndpoint.ts +1 -1
- package/src/endpoints/admin/organizations/PatchOrganizationsEndpoint.ts +8 -8
- package/src/endpoints/auth/CreateAdminEndpoint.ts +2 -2
- package/src/endpoints/auth/CreateTokenEndpoint.ts +10 -10
- package/src/endpoints/auth/ForgotPasswordEndpoint.ts +2 -2
- package/src/endpoints/auth/PatchUserEndpoint.ts +9 -9
- package/src/endpoints/auth/SignupEndpoint.ts +2 -2
- package/src/endpoints/auth/VerifyEmailEndpoint.ts +3 -3
- package/src/endpoints/global/audit-logs/GetAuditLogsEndpoint.ts +1 -1
- package/src/endpoints/global/email/GetEmailAddressEndpoint.ts +1 -1
- package/src/endpoints/global/email/GetEmailEndpoint.ts +1 -1
- package/src/endpoints/global/email/ManageEmailAddressEndpoint.ts +1 -1
- package/src/endpoints/global/email/PatchEmailEndpoint.ts +4 -4
- package/src/endpoints/global/events/GetEventNotificationsEndpoint.ts +1 -1
- package/src/endpoints/global/events/PatchEventNotificationsEndpoint.ts +1 -1
- package/src/endpoints/global/events/PatchEventsEndpoint.ts +22 -16
- package/src/endpoints/global/files/ExportToExcelEndpoint.ts +1 -1
- package/src/endpoints/global/files/UploadFile.ts +14 -2
- package/src/endpoints/global/files/UploadImage.ts +2 -2
- package/src/endpoints/global/members/GetMemberFamilyEndpoint.ts +2 -2
- package/src/endpoints/global/members/GetMembersEndpoint.ts +1 -1
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.test.ts +11 -11
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.ts +34 -34
- package/src/endpoints/global/organizations/CheckRegisterCodeEndpoint.ts +1 -1
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.ts +5 -5
- package/src/endpoints/global/platform/PatchPlatformEnpoint.ts +1 -1
- package/src/endpoints/global/registration/GetPaymentRegistrations.ts +2 -2
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.test.ts +10 -10
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.ts +4 -4
- package/src/endpoints/global/registration/RegisterMembersEndpoint.ts +37 -37
- package/src/endpoints/global/registration-periods/PatchRegistrationPeriodsEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplateXML.ts +1 -1
- package/src/endpoints/organization/dashboard/documents/PatchDocumentEndpoint.ts +5 -5
- package/src/endpoints/organization/dashboard/documents/PatchDocumentTemplateEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/email/CheckEmailBouncesEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.ts +9 -9
- package/src/endpoints/organization/dashboard/organization/SetOrganizationDomainEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/payments/GetMemberBalanceEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/payments/GetPaymentsEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/payments/PatchBalanceItemsEndpoint.ts +11 -11
- package/src/endpoints/organization/dashboard/payments/PatchPaymentsEndpoint.ts +13 -13
- package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.ts +16 -16
- package/src/endpoints/organization/dashboard/stripe/DeleteStripeAccountEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/stripe/GetStripeAccountLinkEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/stripe/GetStripeLoginLinkEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/stripe/UpdateStripeAccountEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/users/CreateApiUserEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/users/DeleteUserEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/users/PatchApiUserEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/webshops/CreateWebshopEndpoint.ts +4 -4
- package/src/endpoints/organization/dashboard/webshops/PatchDiscountCodesEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopEndpoint.ts +8 -8
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopTicketsEndpoint.ts +1 -1
- package/src/endpoints/organization/shared/ExchangePaymentEndpoint.ts +1 -1
- package/src/endpoints/organization/shared/GetDocumentHtml.ts +2 -2
- package/src/endpoints/organization/shared/GetPaymentEndpoint.ts +1 -1
- package/src/endpoints/organization/webshops/CheckWebshopDiscountCodesEndpoint.ts +1 -1
- package/src/endpoints/organization/webshops/GetOrderByPaymentEndpoint.ts +2 -2
- package/src/endpoints/organization/webshops/GetOrderEndpoint.ts +1 -1
- package/src/endpoints/organization/webshops/GetTicketsEndpoint.ts +3 -3
- package/src/endpoints/organization/webshops/GetWebshopEndpoint.ts +1 -1
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.ts +10 -8
- package/src/excel-loaders/event-notifications.ts +11 -11
- package/src/excel-loaders/members.ts +34 -34
- package/src/excel-loaders/organizations.ts +23 -23
- package/src/excel-loaders/payments.ts +39 -39
- package/src/excel-loaders/receivable-balances.ts +21 -21
- package/src/helpers/AddressValidator.ts +6 -6
- package/src/helpers/AdminPermissionChecker.ts +7 -4
- package/src/helpers/AuthenticatedStructures.ts +8 -8
- package/src/helpers/BuckarooHelper.ts +1 -1
- package/src/helpers/Context.ts +3 -3
- package/src/helpers/FileCache.ts +7 -7
- package/src/helpers/ForwardHandler.ts +1 -1
- package/src/helpers/GlobalHelper.ts +6 -4
- package/src/helpers/MembershipCharger.ts +2 -2
- package/src/helpers/SetupStepUpdater.ts +1 -1
- package/src/helpers/StripeHelper.ts +7 -7
- package/src/helpers/XlsxTransformerColumnHelper.ts +18 -18
- package/src/services/DocumentService.ts +1 -1
- package/src/services/EventNotificationService.ts +1 -1
- package/src/services/MemberNumberService.ts +3 -3
- package/src/services/SSOService.ts +5 -5
- package/src/sql-filters/members.ts +1 -1
- package/tests/e2e/private-files.test.ts +3 -3
|
@@ -63,7 +63,7 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
63
63
|
throw new SimpleError({
|
|
64
64
|
code: 'invalid_field',
|
|
65
65
|
message: 'Empty groups',
|
|
66
|
-
human:
|
|
66
|
+
human: $t(`93faf169-b78d-4ad2-b13b-3b974267a632`),
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -71,7 +71,7 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
71
71
|
throw new SimpleError({
|
|
72
72
|
code: 'invalid_field',
|
|
73
73
|
message: 'Empty default age groups',
|
|
74
|
-
human:
|
|
74
|
+
human: $t(`2712befc-5cc5-4013-b8df-ec0861a82c36`),
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -79,7 +79,7 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
79
79
|
throw new SimpleError({
|
|
80
80
|
code: 'invalid_field',
|
|
81
81
|
message: 'Empty organization tag ids',
|
|
82
|
-
human:
|
|
82
|
+
human: $t(`30230574-2956-4e40-ba11-5523c24c0af8`),
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -136,7 +136,7 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
136
136
|
throw new SimpleError({
|
|
137
137
|
code: 'not_found',
|
|
138
138
|
message: 'Event not found',
|
|
139
|
-
human:
|
|
139
|
+
human: $t(`c5f3d2c3-9d7a-473d-ba91-63ce104a2de5`),
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
|
|
@@ -146,7 +146,7 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
146
146
|
throw new SimpleError({
|
|
147
147
|
code: 'invalid_field',
|
|
148
148
|
message: 'Cannot patch organizationCache',
|
|
149
|
-
human:
|
|
149
|
+
human: $t(`74e6eba6-596c-4e55-b178-b2a5fdbca581`),
|
|
150
150
|
field: 'meta.organizationCache',
|
|
151
151
|
});
|
|
152
152
|
}
|
|
@@ -166,7 +166,7 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
166
166
|
throw new SimpleError({
|
|
167
167
|
code: 'invalid_field',
|
|
168
168
|
message: 'Empty groups',
|
|
169
|
-
human:
|
|
169
|
+
human: $t(`93faf169-b78d-4ad2-b13b-3b974267a632`),
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
|
|
@@ -174,7 +174,7 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
174
174
|
throw new SimpleError({
|
|
175
175
|
code: 'invalid_field',
|
|
176
176
|
message: 'Empty default age groups',
|
|
177
|
-
human:
|
|
177
|
+
human: $t(`2712befc-5cc5-4013-b8df-ec0861a82c36`),
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
180
|
|
|
@@ -182,7 +182,7 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
182
182
|
throw new SimpleError({
|
|
183
183
|
code: 'invalid_field',
|
|
184
184
|
message: 'Empty organization tag ids',
|
|
185
|
-
human:
|
|
185
|
+
human: $t(`30230574-2956-4e40-ba11-5523c24c0af8`),
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
|
|
@@ -320,7 +320,7 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
320
320
|
throw new SimpleError({
|
|
321
321
|
code: 'invalid_field',
|
|
322
322
|
message: 'Invalid typeId',
|
|
323
|
-
human:
|
|
323
|
+
human: $t(`6b36fc82-d88c-49cc-ae94-4653ad37b3e3`),
|
|
324
324
|
field: 'typeId',
|
|
325
325
|
});
|
|
326
326
|
}
|
|
@@ -334,7 +334,7 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
334
334
|
throw new SimpleError({
|
|
335
335
|
code: 'invalid_field',
|
|
336
336
|
message: 'Name is too short',
|
|
337
|
-
human:
|
|
337
|
+
human: $t(`53a66432-0bf5-4193-9eb8-dbd52d86a1f8`),
|
|
338
338
|
field: 'name',
|
|
339
339
|
});
|
|
340
340
|
}
|
|
@@ -343,7 +343,7 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
343
343
|
throw new SimpleError({
|
|
344
344
|
code: 'invalid_dates',
|
|
345
345
|
message: 'End date is before start date',
|
|
346
|
-
human:
|
|
346
|
+
human: $t(`318924c0-7a79-4cfa-b206-ffc27c4d32b7`),
|
|
347
347
|
field: 'endDate',
|
|
348
348
|
});
|
|
349
349
|
}
|
|
@@ -360,7 +360,10 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
360
360
|
throw new SimpleError({
|
|
361
361
|
code: 'minimum_days',
|
|
362
362
|
message: 'An event with this type has a minimum of ' + type.minimumDays + ' days',
|
|
363
|
-
human:
|
|
363
|
+
human: $t(`04ff85c0-eb98-46b8-975b-8fd136ddc49a`, {
|
|
364
|
+
name: type.name,
|
|
365
|
+
days: Formatter.pluralText(type.minimumDays, $t(`a6279389-a070-49c9-a085-bb312555e419`), $t(`fca0ce20-d696-4966-a50c-441f54f046c4`)),
|
|
366
|
+
}),
|
|
364
367
|
field: 'startDate',
|
|
365
368
|
});
|
|
366
369
|
}
|
|
@@ -369,7 +372,10 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
369
372
|
throw new SimpleError({
|
|
370
373
|
code: 'maximum_days',
|
|
371
374
|
message: 'An event with this type has a maximum of ' + type.maximumDays + ' days',
|
|
372
|
-
human:
|
|
375
|
+
human: $t(`a7d005aa-ceaa-4323-8fac-a02fce174023`, {
|
|
376
|
+
name: type.name,
|
|
377
|
+
days: Formatter.pluralText(type.maximumDays, $t(`a6279389-a070-49c9-a085-bb312555e419`), $t(`fca0ce20-d696-4966-a50c-441f54f046c4`)),
|
|
378
|
+
}),
|
|
373
379
|
field: 'startDate',
|
|
374
380
|
});
|
|
375
381
|
}
|
|
@@ -393,7 +399,7 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
393
399
|
throw new SimpleError({
|
|
394
400
|
code: 'type_maximum_reached',
|
|
395
401
|
message: 'Maximum number of events with this type reached',
|
|
396
|
-
human:
|
|
402
|
+
human: $t(`fb7df531-0f89-4841-b685-7b2cfb5b507d`) + ' ' + type.name + ' ' + $t(`073d20dc-88f3-4145-89f5-13cc8ad90207`) + type.maximum + ')',
|
|
397
403
|
field: 'typeId',
|
|
398
404
|
});
|
|
399
405
|
}
|
|
@@ -402,7 +408,7 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
402
408
|
throw new SimpleError({
|
|
403
409
|
code: 'invalid_period',
|
|
404
410
|
message: 'No period found for this start date',
|
|
405
|
-
human:
|
|
411
|
+
human: $t(`7a38bf9d-4df7-4827-85dc-327ffe6cd50a`),
|
|
406
412
|
field: 'startDate',
|
|
407
413
|
});
|
|
408
414
|
}
|
|
@@ -420,7 +426,7 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
420
426
|
throw new SimpleError({
|
|
421
427
|
code: 'invalid_field',
|
|
422
428
|
message: 'Empty number',
|
|
423
|
-
human:
|
|
429
|
+
human: $t(`6b72f8bd-cd5b-423f-a556-be102d3c22e9`),
|
|
424
430
|
field: 'event_required',
|
|
425
431
|
});
|
|
426
432
|
}
|
|
@@ -65,7 +65,7 @@ export class ExportToExcelEndpoint extends Endpoint<Params, Query, Body, Respons
|
|
|
65
65
|
throw new SimpleError({
|
|
66
66
|
code: 'not_allowed',
|
|
67
67
|
message: 'Export is pending',
|
|
68
|
-
human:
|
|
68
|
+
human: $t(`a77e6624-bd1f-4374-af5a-d25cc60ee4da`),
|
|
69
69
|
statusCode: 403,
|
|
70
70
|
});
|
|
71
71
|
}
|
|
@@ -58,7 +58,7 @@ export class UploadFile extends Endpoint<Params, Query, Body, ResponseBody> {
|
|
|
58
58
|
await Context.setOptionalOrganizationScope();
|
|
59
59
|
const { user } = await Context.authenticate();
|
|
60
60
|
|
|
61
|
-
if (!Context.auth.canUpload()) {
|
|
61
|
+
if (!Context.auth.canUpload({ private: request.query.isPrivate })) {
|
|
62
62
|
throw Context.auth.error();
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -126,6 +126,18 @@ export class UploadFile extends Endpoint<Params, Query, Body, ResponseBody> {
|
|
|
126
126
|
prefix += '/';
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
prefix += (STAMHOOFD.environment ?? 'development') === 'development' ? ('development/') : ('');
|
|
130
|
+
|
|
131
|
+
// Prepend user id to the file path
|
|
132
|
+
if (request.query.isPrivate && user) {
|
|
133
|
+
// Private files
|
|
134
|
+
prefix += 'users/' + user.id + '/';
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
// Public files
|
|
138
|
+
prefix += 'p/';
|
|
139
|
+
}
|
|
140
|
+
|
|
129
141
|
// Also include the source, in private mode
|
|
130
142
|
const fileId = uuidv4();
|
|
131
143
|
let uploadExt = '';
|
|
@@ -162,7 +174,7 @@ export class UploadFile extends Endpoint<Params, Query, Body, ResponseBody> {
|
|
|
162
174
|
}
|
|
163
175
|
|
|
164
176
|
const filenameWithoutExt = file.originalFilename?.split('.').slice(0, -1).join('.') ?? fileId;
|
|
165
|
-
const key = prefix +
|
|
177
|
+
const key = prefix + fileId + '/' + (Formatter.slug(filenameWithoutExt) + (uploadExt ? ('.' + uploadExt) : ''));
|
|
166
178
|
const params = {
|
|
167
179
|
Bucket: STAMHOOFD.SPACES_BUCKET,
|
|
168
180
|
Key: key,
|
|
@@ -64,7 +64,7 @@ export class UploadImage extends Endpoint<Params, Query, Body, ResponseBody> {
|
|
|
64
64
|
await Context.setOptionalOrganizationScope();
|
|
65
65
|
const { user } = await Context.authenticate();
|
|
66
66
|
|
|
67
|
-
if (!Context.auth.canUpload()) {
|
|
67
|
+
if (!Context.auth.canUpload({ private: request.query.isPrivate })) {
|
|
68
68
|
throw Context.auth.error();
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -131,7 +131,7 @@ export class UploadImage extends Endpoint<Params, Query, Body, ResponseBody> {
|
|
|
131
131
|
});
|
|
132
132
|
|
|
133
133
|
const fileContent = await fs.readFile(file.filepath);
|
|
134
|
-
const image = await Image.create(fileContent, file.mimetype ?? undefined, resolutions, request.query.isPrivate);
|
|
134
|
+
const image = await Image.create(fileContent, file.mimetype ?? undefined, resolutions, request.query.isPrivate, user);
|
|
135
135
|
return new Response(ImageStruct.create(image));
|
|
136
136
|
}
|
|
137
137
|
}
|
|
@@ -55,7 +55,7 @@ export class GetMemberFamilyEndpoint extends Endpoint<Params, Query, Body, Respo
|
|
|
55
55
|
|
|
56
56
|
// Check access to this member (this will automatically give access to the family)
|
|
57
57
|
if (!await Context.auth.canAccessMember(member)) {
|
|
58
|
-
throw Context.auth.error(
|
|
58
|
+
throw Context.auth.error($t(`c9797487-3e24-4686-9bdc-2a7ec9cee8ed`));
|
|
59
59
|
}
|
|
60
60
|
validatedMembers.push(member);
|
|
61
61
|
continue;
|
|
@@ -67,7 +67,7 @@ export class GetMemberFamilyEndpoint extends Endpoint<Params, Query, Body, Respo
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
if (!foundMember) {
|
|
70
|
-
throw Context.auth.error(
|
|
70
|
+
throw Context.auth.error($t(`c9797487-3e24-4686-9bdc-2a7ec9cee8ed`));
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
return new Response(
|
|
@@ -245,7 +245,7 @@ export class GetMembersEndpoint extends Endpoint<Params, Query, Body, ResponseBo
|
|
|
245
245
|
throw new SimpleError({
|
|
246
246
|
code: 'timeout',
|
|
247
247
|
message: 'Query took too long',
|
|
248
|
-
human:
|
|
248
|
+
human: $t(`dce51638-6129-448b-8a15-e6d778f3a76a`),
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
251
|
throw error;
|
|
@@ -2,7 +2,7 @@ import { Database } from '@simonbackx/simple-database';
|
|
|
2
2
|
import { PatchableArray, PatchableArrayAutoEncoder, PatchMap } from '@simonbackx/simple-encoding';
|
|
3
3
|
import { Endpoint, Request } from '@simonbackx/simple-endpoints';
|
|
4
4
|
import { GroupFactory, MemberFactory, OrganizationFactory, OrganizationTagFactory, Platform, RegistrationFactory, Token, UserFactory } from '@stamhoofd/models';
|
|
5
|
-
import { Address, Country, EmergencyContact, MemberDetails, MemberWithRegistrationsBlob, OrganizationMetaData, OrganizationRecordsConfiguration, Parent, PatchAnswers, PermissionLevel, Permissions, PermissionsResourceType, RecordCategory, RecordSettings, RecordTextAnswer, ResourcePermissions, ReviewTime, ReviewTimes } from '@stamhoofd/structures';
|
|
5
|
+
import { Address, Country, EmergencyContact, MemberDetails, MemberWithRegistrationsBlob, OrganizationMetaData, OrganizationRecordsConfiguration, Parent, PatchAnswers, PermissionLevel, Permissions, PermissionsResourceType, RecordCategory, RecordSettings, RecordTextAnswer, ResourcePermissions, ReviewTime, ReviewTimes, TranslatedString } from '@stamhoofd/structures';
|
|
6
6
|
import { SHExpect, TestUtils } from '@stamhoofd/test-utils';
|
|
7
7
|
import { testServer } from '../../../../tests/helpers/TestServer';
|
|
8
8
|
import { PatchOrganizationMembersEndpoint } from './PatchOrganizationMembersEndpoint';
|
|
@@ -357,12 +357,12 @@ describe('Endpoint.PatchOrganizationMembersEndpoint', () => {
|
|
|
357
357
|
describe('Record answers', () => {
|
|
358
358
|
test('An admin can set records of its own organization', async () => {
|
|
359
359
|
const commentsRecord = RecordSettings.create({
|
|
360
|
-
name: 'Opmerkingen',
|
|
360
|
+
name: TranslatedString.create('Opmerkingen'),
|
|
361
361
|
externalPermissionLevel: PermissionLevel.Read, // this should be ignored since we are an admin
|
|
362
362
|
});
|
|
363
363
|
|
|
364
364
|
const recordCategory = RecordCategory.create({
|
|
365
|
-
name: 'Medische fiche',
|
|
365
|
+
name: TranslatedString.create('Medische fiche'),
|
|
366
366
|
records: [
|
|
367
367
|
commentsRecord,
|
|
368
368
|
],
|
|
@@ -426,11 +426,11 @@ describe('Endpoint.PatchOrganizationMembersEndpoint', () => {
|
|
|
426
426
|
|
|
427
427
|
test('An admin with read only record category permission cannot set the records in that category', async () => {
|
|
428
428
|
const commentsRecord = RecordSettings.create({
|
|
429
|
-
name: 'Opmerkingen',
|
|
429
|
+
name: TranslatedString.create('Opmerkingen'),
|
|
430
430
|
});
|
|
431
431
|
|
|
432
432
|
const recordCategory = RecordCategory.create({
|
|
433
|
-
name: 'Medische fiche',
|
|
433
|
+
name: TranslatedString.create('Medische fiche'),
|
|
434
434
|
records: [
|
|
435
435
|
commentsRecord,
|
|
436
436
|
],
|
|
@@ -498,11 +498,11 @@ describe('Endpoint.PatchOrganizationMembersEndpoint', () => {
|
|
|
498
498
|
|
|
499
499
|
test('An admin without record category permission cannot set the records in that category', async () => {
|
|
500
500
|
const commentsRecord = RecordSettings.create({
|
|
501
|
-
name: 'Opmerkingen',
|
|
501
|
+
name: TranslatedString.create('Opmerkingen'),
|
|
502
502
|
});
|
|
503
503
|
|
|
504
504
|
const recordCategory = RecordCategory.create({
|
|
505
|
-
name: 'Medische fiche',
|
|
505
|
+
name: TranslatedString.create('Medische fiche'),
|
|
506
506
|
records: [
|
|
507
507
|
commentsRecord,
|
|
508
508
|
],
|
|
@@ -567,11 +567,11 @@ describe('Endpoint.PatchOrganizationMembersEndpoint', () => {
|
|
|
567
567
|
|
|
568
568
|
test('An admin can set records of the platform', async () => {
|
|
569
569
|
const commentsRecord = RecordSettings.create({
|
|
570
|
-
name: 'Opmerkingen',
|
|
570
|
+
name: TranslatedString.create('Opmerkingen'),
|
|
571
571
|
});
|
|
572
572
|
|
|
573
573
|
const recordCategory = RecordCategory.create({
|
|
574
|
-
name: 'Medische fiche',
|
|
574
|
+
name: TranslatedString.create('Medische fiche'),
|
|
575
575
|
records: [
|
|
576
576
|
commentsRecord,
|
|
577
577
|
],
|
|
@@ -645,11 +645,11 @@ describe('Endpoint.PatchOrganizationMembersEndpoint', () => {
|
|
|
645
645
|
|
|
646
646
|
test('[Regression] A platform admin with tag-access to an organization can change platform records', async () => {
|
|
647
647
|
const commentsRecord = RecordSettings.create({
|
|
648
|
-
name: 'Opmerkingen',
|
|
648
|
+
name: TranslatedString.create('Opmerkingen'),
|
|
649
649
|
});
|
|
650
650
|
|
|
651
651
|
const recordCategory = RecordCategory.create({
|
|
652
|
-
name: 'Medische fiche',
|
|
652
|
+
name: TranslatedString.create('Medische fiche'),
|
|
653
653
|
records: [
|
|
654
654
|
commentsRecord,
|
|
655
655
|
],
|
|
@@ -122,7 +122,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
122
122
|
throw new SimpleError({
|
|
123
123
|
code: 'missing_organization',
|
|
124
124
|
message: 'Missing organization',
|
|
125
|
-
human:
|
|
125
|
+
human: $t(`2bb4647b-a3b8-453e-8b75-41c290910fc8`),
|
|
126
126
|
statusCode: 400,
|
|
127
127
|
});
|
|
128
128
|
}
|
|
@@ -173,7 +173,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
173
173
|
throw new SimpleError({
|
|
174
174
|
code: 'not_allowed',
|
|
175
175
|
message: 'Cannot override details',
|
|
176
|
-
human:
|
|
176
|
+
human: $t(`b66ef4c3-9931-4fc3-9da1-c023857684fa`),
|
|
177
177
|
field: 'details',
|
|
178
178
|
});
|
|
179
179
|
}
|
|
@@ -218,7 +218,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
218
218
|
// Update responsibilities
|
|
219
219
|
for (const patchResponsibility of patch.responsibilities.getPatches()) {
|
|
220
220
|
if (!Context.auth.hasPlatformFullAccess() && !(organization && await Context.auth.hasFullAccess(organization.id))) {
|
|
221
|
-
throw Context.auth.error(
|
|
221
|
+
throw Context.auth.error($t(`1d1b5807-af39-400b-8dea-2f222ee668ae`));
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
const responsibilityRecord = await MemberResponsibilityRecord.getByID(patchResponsibility.id);
|
|
@@ -226,21 +226,21 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
226
226
|
throw new SimpleError({
|
|
227
227
|
code: 'permission_denied',
|
|
228
228
|
message: "You don't have permissions to access this endpoint",
|
|
229
|
-
human:
|
|
229
|
+
human: $t(`738fc35a-da77-4e1a-8233-9ff651781f65`),
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
const responsibility = platform.config.responsibilities.find(r => r.id === patchResponsibility.responsibilityId);
|
|
234
234
|
|
|
235
235
|
if (responsibility && !responsibility.organizationBased && !Context.auth.hasPlatformFullAccess()) {
|
|
236
|
-
throw Context.auth.error(
|
|
236
|
+
throw Context.auth.error($t(`e2ceec71-367c-4cfd-98f3-b0ec0c83e2c2`));
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
// Allow patching begin and end date
|
|
240
240
|
if (patchResponsibility.endDate !== undefined) {
|
|
241
241
|
if (responsibilityRecord.endDate) {
|
|
242
242
|
if (!Context.auth.hasPlatformFullAccess()) {
|
|
243
|
-
throw Context.auth.error(
|
|
243
|
+
throw Context.auth.error($t(`fd88b6ba-1f0b-4e82-9c5b-7c7a3ac8f4fa`));
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
responsibilityRecord.endDate = patchResponsibility.endDate;
|
|
@@ -248,7 +248,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
248
248
|
|
|
249
249
|
if (patchResponsibility.startDate !== undefined) {
|
|
250
250
|
if (patchResponsibility.startDate.getTime() > Date.now() + 5 * 60 * 1000) {
|
|
251
|
-
throw Context.auth.error(
|
|
251
|
+
throw Context.auth.error($t(`84c2346e-40b2-4b38-9b2d-e1fcba6f1202`));
|
|
252
252
|
}
|
|
253
253
|
if (patchResponsibility.startDate.getTime() > Date.now()) {
|
|
254
254
|
patchResponsibility.startDate = new Date(); // force now
|
|
@@ -257,7 +257,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
257
257
|
const daysDiff = Math.abs((new Date().getTime() - patchResponsibility.startDate.getTime()) / (1000 * 60 * 60 * 24));
|
|
258
258
|
|
|
259
259
|
if (daysDiff > 60 && !Context.auth.hasPlatformFullAccess()) {
|
|
260
|
-
throw Context.auth.error(
|
|
260
|
+
throw Context.auth.error($t(`dc0c8bff-7b16-4597-adfb-cd6a4d7d4bf1`));
|
|
261
261
|
}
|
|
262
262
|
responsibilityRecord.startDate = patchResponsibility.startDate;
|
|
263
263
|
}
|
|
@@ -274,7 +274,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
274
274
|
// Create responsibilities
|
|
275
275
|
for (const { put } of patch.responsibilities.getPuts()) {
|
|
276
276
|
if (!Context.auth.hasPlatformFullAccess() && !(organization && await Context.auth.hasFullAccess(organization.id))) {
|
|
277
|
-
throw Context.auth.error(
|
|
277
|
+
throw Context.auth.error($t(`1d1b5807-af39-400b-8dea-2f222ee668ae`));
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
const platformResponsibility = platform.config.responsibilities.find(r => r.id === put.responsibilityId);
|
|
@@ -284,7 +284,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
284
284
|
throw new SimpleError({
|
|
285
285
|
code: 'invalid_field',
|
|
286
286
|
message: 'Invalid organization',
|
|
287
|
-
human:
|
|
287
|
+
human: $t(`31757907-4cdd-4f0e-bb9d-cba9c1d997e4`),
|
|
288
288
|
field: 'organizationId',
|
|
289
289
|
});
|
|
290
290
|
}
|
|
@@ -294,7 +294,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
294
294
|
throw new SimpleError({
|
|
295
295
|
code: 'invalid_field',
|
|
296
296
|
message: 'Invalid responsibility',
|
|
297
|
-
human:
|
|
297
|
+
human: $t(`03114785-acf5-4bba-a3b5-15d3ac4ae17c`),
|
|
298
298
|
field: 'responsibilityId',
|
|
299
299
|
});
|
|
300
300
|
}
|
|
@@ -303,7 +303,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
303
303
|
throw new SimpleError({
|
|
304
304
|
code: 'invalid_field',
|
|
305
305
|
message: 'Invalid organization',
|
|
306
|
-
human:
|
|
306
|
+
human: $t(`ed22b0bb-8ae7-4ef0-a139-1bc11b2a719e`),
|
|
307
307
|
field: 'organizationId',
|
|
308
308
|
});
|
|
309
309
|
}
|
|
@@ -345,7 +345,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
345
345
|
throw new SimpleError({
|
|
346
346
|
code: 'invalid_field',
|
|
347
347
|
message: 'Invalid organization',
|
|
348
|
-
human:
|
|
348
|
+
human: $t(`aa39f949-6fe5-4ed2-acb7-ff3d138cf243`),
|
|
349
349
|
field: 'organizationId',
|
|
350
350
|
});
|
|
351
351
|
}
|
|
@@ -355,7 +355,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
355
355
|
throw new SimpleError({
|
|
356
356
|
code: 'invalid_field',
|
|
357
357
|
message: 'Missing groupId',
|
|
358
|
-
human:
|
|
358
|
+
human: $t(`8bfe005a-a98a-48d6-afbf-bcca487b064b`),
|
|
359
359
|
field: 'groupId',
|
|
360
360
|
});
|
|
361
361
|
}
|
|
@@ -365,7 +365,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
365
365
|
throw new SimpleError({
|
|
366
366
|
code: 'invalid_field',
|
|
367
367
|
message: 'Invalid groupId',
|
|
368
|
-
human:
|
|
368
|
+
human: $t(`ca86d6ef-990e-42a4-834c-1c94622c95ef`),
|
|
369
369
|
field: 'groupId',
|
|
370
370
|
});
|
|
371
371
|
}
|
|
@@ -374,7 +374,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
374
374
|
throw new SimpleError({
|
|
375
375
|
code: 'invalid_field',
|
|
376
376
|
message: 'Invalid groupId',
|
|
377
|
-
human:
|
|
377
|
+
human: $t(`aed1d5e3-1d42-46d4-a9c1-ac13bdffc2bd`),
|
|
378
378
|
field: 'groupId',
|
|
379
379
|
});
|
|
380
380
|
}
|
|
@@ -386,7 +386,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
386
386
|
model.endDate = put.endDate;
|
|
387
387
|
|
|
388
388
|
if (put.startDate.getTime() > Date.now() + 5 * 60 * 1000) {
|
|
389
|
-
throw Context.auth.error(
|
|
389
|
+
throw Context.auth.error($t(`84c2346e-40b2-4b38-9b2d-e1fcba6f1202`));
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
if (put.startDate.getTime() > Date.now()) {
|
|
@@ -394,7 +394,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
394
394
|
}
|
|
395
395
|
|
|
396
396
|
if (put.endDate && put.endDate > new Date(Date.now() + 60 * 1000)) {
|
|
397
|
-
throw Context.auth.error(
|
|
397
|
+
throw Context.auth.error($t(`5c6106e8-6785-4f72-b0c7-00a940240019`));
|
|
398
398
|
}
|
|
399
399
|
|
|
400
400
|
model.startDate = put.startDate;
|
|
@@ -421,7 +421,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
421
421
|
throw new SimpleError({
|
|
422
422
|
code: 'invalid_field',
|
|
423
423
|
message: 'Invalid email',
|
|
424
|
-
human:
|
|
424
|
+
human: $t(`dcb9cd60-ddfe-403d-bfb7-d1c7b63e2fdf`),
|
|
425
425
|
});
|
|
426
426
|
}
|
|
427
427
|
|
|
@@ -457,13 +457,13 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
457
457
|
throw new SimpleError({
|
|
458
458
|
code: 'invalid_field',
|
|
459
459
|
message: 'Invalid organization',
|
|
460
|
-
human:
|
|
460
|
+
human: $t(`601c15e5-cfb0-4c34-af03-7dfc55e39d36`),
|
|
461
461
|
field: 'organizationId',
|
|
462
462
|
});
|
|
463
463
|
}
|
|
464
464
|
|
|
465
465
|
if (!await Context.auth.hasFullAccess(put.organizationId)) {
|
|
466
|
-
throw Context.auth.error(
|
|
466
|
+
throw Context.auth.error($t(`9c632c7f-242e-44a1-b8ad-335b613075d8`));
|
|
467
467
|
}
|
|
468
468
|
|
|
469
469
|
const putForOrganization = await Context.auth.getOrganization(put.organizationId);
|
|
@@ -475,7 +475,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
475
475
|
code: 'invalid_field',
|
|
476
476
|
field: 'membershipTypeId',
|
|
477
477
|
message: 'Invalid membership type',
|
|
478
|
-
human:
|
|
478
|
+
human: $t(`fa79b34e-deef-4379-9c80-8795b0f5eaa3`),
|
|
479
479
|
});
|
|
480
480
|
}
|
|
481
481
|
|
|
@@ -497,7 +497,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
497
497
|
code: 'invalid_field',
|
|
498
498
|
field: 'membershipTypeId',
|
|
499
499
|
message: 'Invalid membership type',
|
|
500
|
-
human:
|
|
500
|
+
human: $t(`a17551ff-5097-4f09-a8bb-19fe377f2b98`),
|
|
501
501
|
});
|
|
502
502
|
}
|
|
503
503
|
|
|
@@ -543,7 +543,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
543
543
|
code: 'invalid_field',
|
|
544
544
|
field: 'startDate',
|
|
545
545
|
message: 'Invalid start date',
|
|
546
|
-
human:
|
|
546
|
+
human: $t(`faf8b6bb-2727-4d2f-847f-203cf3979dfb`),
|
|
547
547
|
});
|
|
548
548
|
}
|
|
549
549
|
|
|
@@ -561,12 +561,12 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
561
561
|
code: 'invalid_field',
|
|
562
562
|
field: 'id',
|
|
563
563
|
message: 'Invalid id',
|
|
564
|
-
human:
|
|
564
|
+
human: $t(`ee79372d-c14d-41ab-afb1-336acbe52687`),
|
|
565
565
|
});
|
|
566
566
|
}
|
|
567
567
|
|
|
568
568
|
if (!await Context.auth.hasFullAccess(membership.organizationId)) {
|
|
569
|
-
throw Context.auth.error(
|
|
569
|
+
throw Context.auth.error($t(`fa5797d7-dafb-469a-a75c-b3b8a6a08737`));
|
|
570
570
|
}
|
|
571
571
|
|
|
572
572
|
if (membership.periodId !== platform.periodId) {
|
|
@@ -619,12 +619,12 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
619
619
|
code: 'invalid_field',
|
|
620
620
|
field: 'id',
|
|
621
621
|
message: 'Invalid id',
|
|
622
|
-
human:
|
|
622
|
+
human: $t(`ee79372d-c14d-41ab-afb1-336acbe52687`),
|
|
623
623
|
});
|
|
624
624
|
}
|
|
625
625
|
|
|
626
626
|
if (!await Context.auth.hasFullAccess(membership.organizationId)) {
|
|
627
|
-
throw Context.auth.error(
|
|
627
|
+
throw Context.auth.error($t(`c3cca571-d543-4ca7-9da1-1e5570f5063a`));
|
|
628
628
|
}
|
|
629
629
|
|
|
630
630
|
if (membership.periodId !== platform.periodId) {
|
|
@@ -654,14 +654,14 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
654
654
|
throw new SimpleError({
|
|
655
655
|
code: 'invalid_field',
|
|
656
656
|
message: 'Invalid invoice',
|
|
657
|
-
human:
|
|
657
|
+
human: $t(`be7d7286-9c3f-41f9-9378-b028754c8533`),
|
|
658
658
|
});
|
|
659
659
|
}
|
|
660
660
|
|
|
661
661
|
throw new SimpleError({
|
|
662
662
|
code: 'invalid_field',
|
|
663
663
|
message: 'Invalid invoice',
|
|
664
|
-
human:
|
|
664
|
+
human: $t(`1a7b41da-9bd3-4019-9ed4-39e742f99f41`),
|
|
665
665
|
});
|
|
666
666
|
}
|
|
667
667
|
|
|
@@ -709,7 +709,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
709
709
|
for (const id of ids) {
|
|
710
710
|
const member = await Member.getWithRegistrations(id);
|
|
711
711
|
if (!member || !await Context.auth.canDeleteMember(member)) {
|
|
712
|
-
throw Context.auth.error(
|
|
712
|
+
throw Context.auth.error($t(`39f5696c-3755-429f-b0da-a0ca920ed11e`));
|
|
713
713
|
}
|
|
714
714
|
|
|
715
715
|
await MemberUserSyncer.onDeleteMember(member);
|
|
@@ -901,14 +901,14 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
901
901
|
}
|
|
902
902
|
catch (e) {
|
|
903
903
|
Email.sendWebmaster({
|
|
904
|
-
subject:
|
|
905
|
-
text:
|
|
904
|
+
subject: $t(`04cb945a-28aa-4f3e-95b3-16455cdd8892`),
|
|
905
|
+
text: $t(`5f7b1766-eb58-4471-bff7-60f3fc66fe41`) + ' ' + member.details.name + ' ' + $t(`7254f2f6-0d15-4e81-85cf-cff6438c9e98`) + ' ' + member.id + ')' + '\n\n' + e.message + '\n\nStamhoofd',
|
|
906
906
|
});
|
|
907
907
|
|
|
908
908
|
throw new SimpleError({
|
|
909
909
|
code: 'too_many_tries',
|
|
910
910
|
message: 'Too many securityCodes limited',
|
|
911
|
-
human:
|
|
911
|
+
human: $t(`ddb1b9de-cc00-4960-ba36-fa70429cbac1`),
|
|
912
912
|
field: 'details.securityCode',
|
|
913
913
|
});
|
|
914
914
|
}
|
|
@@ -36,7 +36,7 @@ export class CheckRegisterCodeEndpoint extends Endpoint<Params, Query, Body, Res
|
|
|
36
36
|
throw new SimpleError({
|
|
37
37
|
code: 'invalid_code',
|
|
38
38
|
message: 'Invalid code',
|
|
39
|
-
human:
|
|
39
|
+
human: $t(`d46c176d-780c-4484-a510-7fcbe0e31555`),
|
|
40
40
|
field: 'registerCode',
|
|
41
41
|
});
|
|
42
42
|
}
|