@stamhoofd/models 2.39.0 → 2.40.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/dist/src/factories/AddressFactory.d.ts +3 -4
- package/dist/src/factories/AddressFactory.d.ts.map +1 -1
- package/dist/src/factories/AddressFactory.js +13 -13
- package/dist/src/factories/EmergencyContactFactory.d.ts +3 -4
- package/dist/src/factories/EmergencyContactFactory.d.ts.map +1 -1
- package/dist/src/factories/EmergencyContactFactory.js +27 -27
- package/dist/src/factories/EmergencyContactFactory.js.map +1 -1
- package/dist/src/factories/GroupFactory.d.ts +4 -4
- package/dist/src/factories/GroupFactory.d.ts.map +1 -1
- package/dist/src/factories/GroupFactory.js +8 -8
- package/dist/src/factories/GroupFactory.js.map +1 -1
- package/dist/src/factories/MemberFactory.d.ts +4 -4
- package/dist/src/factories/MemberFactory.d.ts.map +1 -1
- package/dist/src/factories/MemberFactory.js +17 -17
- package/dist/src/factories/MemberFactory.js.map +1 -1
- package/dist/src/factories/OrganizationFactory.d.ts +4 -4
- package/dist/src/factories/OrganizationFactory.js +8 -8
- package/dist/src/factories/OrganizationFactory.js.map +1 -1
- package/dist/src/factories/ParentFactory.d.ts +1 -1
- package/dist/src/factories/ParentFactory.js +19 -19
- package/dist/src/factories/ParentFactory.js.map +1 -1
- package/dist/src/factories/RecordFactory.d.ts +2 -3
- package/dist/src/factories/RecordFactory.d.ts.map +1 -1
- package/dist/src/factories/RecordFactory.js +1 -1
- package/dist/src/factories/RecordFactory.js.map +1 -1
- package/dist/src/factories/RegisterCodeFactory.d.ts +2 -2
- package/dist/src/factories/RegisterCodeFactory.d.ts.map +1 -1
- package/dist/src/factories/RegisterCodeFactory.js +2 -2
- package/dist/src/factories/RegistrationFactory.d.ts +3 -3
- package/dist/src/factories/RegistrationFactory.d.ts.map +1 -1
- package/dist/src/factories/RegistrationFactory.js.map +1 -1
- package/dist/src/factories/RegistrationPeriodFactory.d.ts +2 -2
- package/dist/src/factories/RegistrationPeriodFactory.js.map +1 -1
- package/dist/src/factories/UserFactory.d.ts +3 -3
- package/dist/src/factories/UserFactory.d.ts.map +1 -1
- package/dist/src/factories/UserFactory.js +3 -3
- package/dist/src/factories/UserFactory.js.map +1 -1
- package/dist/src/factories/WebshopFactory.d.ts +4 -4
- package/dist/src/factories/WebshopFactory.d.ts.map +1 -1
- package/dist/src/factories/WebshopFactory.js +1 -1
- package/dist/src/factories/WebshopFactory.js.map +1 -1
- package/dist/src/helpers/DNSValidator.d.ts +1 -1
- package/dist/src/helpers/DNSValidator.d.ts.map +1 -1
- package/dist/src/helpers/DNSValidator.js +33 -33
- package/dist/src/helpers/DNSValidator.js.map +1 -1
- package/dist/src/helpers/EmailBuilder.d.ts +10 -10
- package/dist/src/helpers/EmailBuilder.d.ts.map +1 -1
- package/dist/src/helpers/EmailBuilder.js +34 -34
- package/dist/src/helpers/EmailBuilder.js.map +1 -1
- package/dist/src/helpers/GroupBuilder.d.ts.map +1 -1
- package/dist/src/helpers/GroupBuilder.js +57 -57
- package/dist/src/helpers/GroupBuilder.js.map +1 -1
- package/dist/src/helpers/Handlebars.d.ts.map +1 -1
- package/dist/src/helpers/Handlebars.js +29 -29
- package/dist/src/helpers/Handlebars.js.map +1 -1
- package/dist/src/helpers/MemberMerger.d.ts +1 -1
- package/dist/src/helpers/MemberMerger.d.ts.map +1 -1
- package/dist/src/helpers/MemberMerger.js +33 -33
- package/dist/src/helpers/MemberMerger.js.map +1 -1
- package/dist/src/helpers/MemberMerger.test.js +194 -194
- package/dist/src/helpers/MemberMerger.test.js.map +1 -1
- package/dist/src/helpers/RateLimiter.d.ts.map +1 -1
- package/dist/src/helpers/RateLimiter.js +2 -2
- package/dist/src/helpers/RateLimiter.js.map +1 -1
- package/dist/src/helpers/SetupStepsUpdater.d.ts +22 -0
- package/dist/src/helpers/SetupStepsUpdater.d.ts.map +1 -0
- package/dist/src/helpers/SetupStepsUpdater.js +255 -0
- package/dist/src/helpers/SetupStepsUpdater.js.map +1 -0
- package/dist/src/helpers/WebshopCounter.d.ts +1 -1
- package/dist/src/helpers/WebshopCounter.d.ts.map +1 -1
- package/dist/src/helpers/WebshopCounter.js +1 -1
- package/dist/src/helpers/WebshopCounter.js.map +1 -1
- package/dist/src/helpers/WebshopCounter.test.js +6 -6
- package/dist/src/helpers/WebshopCounter.test.js.map +1 -1
- package/dist/src/index.d.ts +20 -19
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/migrations/1605262045-import-postcodes.js +12 -12
- package/dist/src/migrations/1605262046-import-postcodes-nl.js +10 -10
- package/dist/src/models/BalanceItem.d.ts.map +1 -1
- package/dist/src/models/BalanceItem.js +37 -37
- package/dist/src/models/BalanceItem.js.map +1 -1
- package/dist/src/models/BalanceItemPayment.d.ts.map +1 -1
- package/dist/src/models/BalanceItemPayment.js +13 -13
- package/dist/src/models/BalanceItemPayment.js.map +1 -1
- package/dist/src/models/BuckarooPayment.d.ts +1 -1
- package/dist/src/models/BuckarooPayment.d.ts.map +1 -1
- package/dist/src/models/BuckarooPayment.js +5 -5
- package/dist/src/models/BuckarooPayment.js.map +1 -1
- package/dist/src/models/CachedOutstandingBalance.d.ts.map +1 -1
- package/dist/src/models/CachedOutstandingBalance.js +37 -37
- package/dist/src/models/CachedOutstandingBalance.js.map +1 -1
- package/dist/src/models/Document.d.ts +4 -4
- package/dist/src/models/Document.d.ts.map +1 -1
- package/dist/src/models/Document.js +27 -27
- package/dist/src/models/Document.js.map +1 -1
- package/dist/src/models/DocumentTemplate.d.ts +4 -4
- package/dist/src/models/DocumentTemplate.d.ts.map +1 -1
- package/dist/src/models/DocumentTemplate.js +72 -72
- package/dist/src/models/DocumentTemplate.js.map +1 -1
- package/dist/src/models/Email.d.ts.map +1 -1
- package/dist/src/models/Email.js +63 -64
- package/dist/src/models/Email.js.map +1 -1
- package/dist/src/models/EmailRecipient.d.ts.map +1 -1
- package/dist/src/models/EmailRecipient.js +20 -20
- package/dist/src/models/EmailRecipient.js.map +1 -1
- package/dist/src/models/EmailTemplate.d.ts +3 -3
- package/dist/src/models/EmailTemplate.d.ts.map +1 -1
- package/dist/src/models/EmailTemplate.js +16 -16
- package/dist/src/models/EmailTemplate.js.map +1 -1
- package/dist/src/models/EmailVerificationCode.d.ts +2 -2
- package/dist/src/models/EmailVerificationCode.d.ts.map +1 -1
- package/dist/src/models/EmailVerificationCode.js +57 -55
- package/dist/src/models/EmailVerificationCode.js.map +1 -1
- package/dist/src/models/Event.d.ts +2 -2
- package/dist/src/models/Event.d.ts.map +1 -1
- package/dist/src/models/Event.js +15 -15
- package/dist/src/models/Event.js.map +1 -1
- package/dist/src/models/Group.d.ts +3 -1
- package/dist/src/models/Group.d.ts.map +1 -1
- package/dist/src/models/Group.js +46 -35
- package/dist/src/models/Group.js.map +1 -1
- package/dist/src/models/Image.d.ts +1 -1
- package/dist/src/models/Image.d.ts.map +1 -1
- package/dist/src/models/Image.js +26 -26
- package/dist/src/models/Image.js.map +1 -1
- package/dist/src/models/Member.d.ts +8 -8
- package/dist/src/models/Member.d.ts.map +1 -1
- package/dist/src/models/Member.js +60 -60
- package/dist/src/models/Member.js.map +1 -1
- package/dist/src/models/MemberPlatformMembership.d.ts +3 -3
- package/dist/src/models/MemberPlatformMembership.d.ts.map +1 -1
- package/dist/src/models/MemberPlatformMembership.js +26 -26
- package/dist/src/models/MemberPlatformMembership.js.map +1 -1
- package/dist/src/models/MemberResponsibilityRecord.d.ts.map +1 -1
- package/dist/src/models/MemberResponsibilityRecord.js +13 -13
- package/dist/src/models/MemberResponsibilityRecord.js.map +1 -1
- package/dist/src/models/MergedMember.d.ts +3 -3
- package/dist/src/models/MergedMember.d.ts.map +1 -1
- package/dist/src/models/MergedMember.js +19 -19
- package/dist/src/models/MergedMember.js.map +1 -1
- package/dist/src/models/MolliePayment.d.ts +1 -1
- package/dist/src/models/MolliePayment.d.ts.map +1 -1
- package/dist/src/models/MolliePayment.js +5 -5
- package/dist/src/models/MolliePayment.js.map +1 -1
- package/dist/src/models/MollieToken.d.ts.map +1 -1
- package/dist/src/models/MollieToken.js +60 -60
- package/dist/src/models/MollieToken.js.map +1 -1
- package/dist/src/models/OneTimeToken.d.ts +2 -2
- package/dist/src/models/OneTimeToken.d.ts.map +1 -1
- package/dist/src/models/OneTimeToken.js +13 -13
- package/dist/src/models/OneTimeToken.js.map +1 -1
- package/dist/src/models/Order.d.ts +1 -1
- package/dist/src/models/Order.d.ts.map +1 -1
- package/dist/src/models/Order.js +70 -70
- package/dist/src/models/Order.js.map +1 -1
- package/dist/src/models/Organization.d.ts +5 -5
- package/dist/src/models/Organization.d.ts.map +1 -1
- package/dist/src/models/Organization.js +127 -127
- package/dist/src/models/Organization.js.map +1 -1
- package/dist/src/models/OrganizationRegistrationPeriod.d.ts.map +1 -1
- package/dist/src/models/OrganizationRegistrationPeriod.js +15 -15
- package/dist/src/models/OrganizationRegistrationPeriod.js.map +1 -1
- package/dist/src/models/PasswordToken.d.ts +3 -3
- package/dist/src/models/PasswordToken.d.ts.map +1 -1
- package/dist/src/models/PasswordToken.js +17 -17
- package/dist/src/models/PasswordToken.js.map +1 -1
- package/dist/src/models/PayconiqPayment.d.ts +1 -1
- package/dist/src/models/PayconiqPayment.d.ts.map +1 -1
- package/dist/src/models/PayconiqPayment.js +49 -49
- package/dist/src/models/PayconiqPayment.js.map +1 -1
- package/dist/src/models/Payment.d.ts +3 -3
- package/dist/src/models/Payment.d.ts.map +1 -1
- package/dist/src/models/Payment.js +36 -36
- package/dist/src/models/Payment.js.map +1 -1
- package/dist/src/models/Platform.d.ts +2 -2
- package/dist/src/models/Platform.d.ts.map +1 -1
- package/dist/src/models/Platform.js +8 -8
- package/dist/src/models/Platform.js.map +1 -1
- package/dist/src/models/RegisterCode.d.ts +1 -1
- package/dist/src/models/RegisterCode.d.ts.map +1 -1
- package/dist/src/models/RegisterCode.js +11 -11
- package/dist/src/models/RegisterCode.js.map +1 -1
- package/dist/src/models/Registration.d.ts +1 -1
- package/dist/src/models/Registration.d.ts.map +1 -1
- package/dist/src/models/Registration.js +88 -88
- package/dist/src/models/Registration.js.map +1 -1
- package/dist/src/models/RegistrationPeriod.d.ts.map +1 -1
- package/dist/src/models/RegistrationPeriod.js +12 -12
- package/dist/src/models/RegistrationPeriod.js.map +1 -1
- package/dist/src/models/STCredit.d.ts +1 -1
- package/dist/src/models/STCredit.d.ts.map +1 -1
- package/dist/src/models/STCredit.js +12 -12
- package/dist/src/models/STCredit.js.map +1 -1
- package/dist/src/models/STInvoice.d.ts +1 -1
- package/dist/src/models/STInvoice.d.ts.map +1 -1
- package/dist/src/models/STInvoice.js +16 -16
- package/dist/src/models/STInvoice.js.map +1 -1
- package/dist/src/models/STPackage.d.ts +1 -1
- package/dist/src/models/STPackage.d.ts.map +1 -1
- package/dist/src/models/STPackage.js +39 -39
- package/dist/src/models/STPackage.js.map +1 -1
- package/dist/src/models/STPendingInvoice.d.ts +1 -1
- package/dist/src/models/STPendingInvoice.d.ts.map +1 -1
- package/dist/src/models/STPendingInvoice.js +11 -11
- package/dist/src/models/STPendingInvoice.js.map +1 -1
- package/dist/src/models/StripeAccount.d.ts.map +1 -1
- package/dist/src/models/StripeAccount.js +13 -13
- package/dist/src/models/StripeAccount.js.map +1 -1
- package/dist/src/models/StripeCheckoutSession.d.ts +1 -1
- package/dist/src/models/StripeCheckoutSession.d.ts.map +1 -1
- package/dist/src/models/StripeCheckoutSession.js +7 -7
- package/dist/src/models/StripeCheckoutSession.js.map +1 -1
- package/dist/src/models/StripePaymentIntent.d.ts +1 -1
- package/dist/src/models/StripePaymentIntent.d.ts.map +1 -1
- package/dist/src/models/StripePaymentIntent.js +7 -7
- package/dist/src/models/StripePaymentIntent.js.map +1 -1
- package/dist/src/models/Ticket.d.ts +2 -2
- package/dist/src/models/Ticket.d.ts.map +1 -1
- package/dist/src/models/Ticket.js +23 -23
- package/dist/src/models/Ticket.js.map +1 -1
- package/dist/src/models/Token.d.ts +3 -3
- package/dist/src/models/Token.d.ts.map +1 -1
- package/dist/src/models/Token.js +27 -27
- package/dist/src/models/Token.js.map +1 -1
- package/dist/src/models/Token.test.js +11 -11
- package/dist/src/models/UsedRegisterCode.d.ts +1 -1
- package/dist/src/models/UsedRegisterCode.d.ts.map +1 -1
- package/dist/src/models/UsedRegisterCode.js +10 -10
- package/dist/src/models/UsedRegisterCode.js.map +1 -1
- package/dist/src/models/User.d.ts +4 -4
- package/dist/src/models/User.d.ts.map +1 -1
- package/dist/src/models/User.js +53 -51
- package/dist/src/models/User.js.map +1 -1
- package/dist/src/models/UserPermissions.d.ts +3 -3
- package/dist/src/models/UserPermissions.d.ts.map +1 -1
- package/dist/src/models/UserPermissions.js +12 -12
- package/dist/src/models/UserPermissions.js.map +1 -1
- package/dist/src/models/Webshop.d.ts +1 -1
- package/dist/src/models/Webshop.d.ts.map +1 -1
- package/dist/src/models/Webshop.js +23 -23
- package/dist/src/models/Webshop.js.map +1 -1
- package/dist/src/models/WebshopDiscountCode.d.ts +1 -1
- package/dist/src/models/WebshopDiscountCode.d.ts.map +1 -1
- package/dist/src/models/WebshopDiscountCode.js +16 -16
- package/dist/src/models/WebshopDiscountCode.js.map +1 -1
- package/dist/src/models/addresses/City.d.ts.map +1 -1
- package/dist/src/models/addresses/City.js +9 -9
- package/dist/src/models/addresses/City.js.map +1 -1
- package/dist/src/models/addresses/PostalCode.d.ts.map +1 -1
- package/dist/src/models/addresses/PostalCode.js +11 -11
- package/dist/src/models/addresses/PostalCode.js.map +1 -1
- package/dist/src/models/addresses/PostalCode.test.js +22 -22
- package/dist/src/models/addresses/PostalCode.test.js.map +1 -1
- package/dist/src/models/addresses/Province.d.ts.map +1 -1
- package/dist/src/models/addresses/Province.js +5 -5
- package/dist/src/models/addresses/Province.js.map +1 -1
- package/dist/src/models/addresses/Street.d.ts.map +1 -1
- package/dist/src/models/addresses/Street.js +6 -6
- package/dist/src/models/addresses/Street.js.map +1 -1
- package/dist/src/models/index.d.ts +46 -46
- package/dist/src/models/index.d.ts.map +1 -1
- package/dist/src/models/index.js +0 -1
- package/dist/src/models/index.js.map +1 -1
- package/dist/src/structures/OrganizationServerMetaData.d.ts.map +1 -1
- package/dist/src/structures/OrganizationServerMetaData.js +4 -4
- package/dist/src/structures/OrganizationServerMetaData.js.map +1 -1
- package/dist/tests/jest.global.setup.d.ts.map +1 -1
- package/dist/tests/jest.global.setup.js +15 -13
- package/dist/tests/jest.global.setup.js.map +1 -1
- package/dist/tests/jest.setup.js +3 -1
- package/dist/tests/jest.setup.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +3 -3
- package/src/factories/AddressFactory.ts +17 -17
- package/src/factories/EmergencyContactFactory.ts +30 -31
- package/src/factories/GroupFactory.ts +30 -30
- package/src/factories/MemberFactory.ts +41 -38
- package/src/factories/OrganizationFactory.ts +15 -15
- package/src/factories/ParentFactory.ts +24 -24
- package/src/factories/RecordFactory.ts +5 -4
- package/src/factories/RegisterCodeFactory.ts +7 -7
- package/src/factories/RegistrationFactory.ts +16 -16
- package/src/factories/RegistrationPeriodFactory.ts +5 -5
- package/src/factories/UserFactory.ts +20 -19
- package/src/factories/WebshopFactory.ts +14 -14
- package/src/helpers/DNSValidator.ts +89 -84
- package/src/helpers/EmailBuilder.ts +141 -135
- package/src/helpers/GroupBuilder.ts +181 -181
- package/src/helpers/Handlebars.ts +57 -54
- package/src/helpers/MemberMerger.test.ts +702 -702
- package/src/helpers/MemberMerger.ts +83 -77
- package/src/helpers/RateLimiter.ts +25 -27
- package/src/helpers/SetupStepsUpdater.ts +402 -0
- package/src/helpers/WebshopCounter.test.ts +12 -12
- package/src/helpers/WebshopCounter.ts +20 -19
- package/src/index.ts +20 -19
- package/src/migrations/1605262045-import-postcodes.ts +59 -63
- package/src/migrations/1605262046-import-postcodes-nl.ts +41 -43
- package/src/models/BalanceItem.ts +173 -172
- package/src/models/BalanceItemPayment.ts +32 -33
- package/src/models/BuckarooPayment.ts +7 -7
- package/src/models/CachedOutstandingBalance.ts +98 -99
- package/src/models/Document.ts +90 -87
- package/src/models/DocumentTemplate.ts +207 -198
- package/src/models/Email.ts +198 -200
- package/src/models/EmailRecipient.ts +38 -39
- package/src/models/EmailTemplate.ts +36 -37
- package/src/models/EmailVerificationCode.ts +146 -142
- package/src/models/Event.ts +53 -53
- package/src/models/Group.ts +136 -123
- package/src/models/Image.ts +48 -48
- package/src/models/Member.ts +277 -275
- package/src/models/MemberPlatformMembership.ts +71 -71
- package/src/models/MemberResponsibilityRecord.ts +32 -32
- package/src/models/MergedMember.ts +77 -77
- package/src/models/MolliePayment.ts +7 -7
- package/src/models/MollieToken.ts +131 -126
- package/src/models/OneTimeToken.ts +40 -39
- package/src/models/Order.ts +379 -372
- package/src/models/Organization.ts +332 -325
- package/src/models/OrganizationRegistrationPeriod.ts +50 -50
- package/src/models/PasswordToken.ts +42 -42
- package/src/models/PayconiqPayment.ts +80 -76
- package/src/models/Payment.ts +86 -86
- package/src/models/Platform.ts +21 -22
- package/src/models/RegisterCode.ts +26 -26
- package/src/models/Registration.ts +167 -168
- package/src/models/RegistrationPeriod.ts +29 -29
- package/src/models/STCredit.ts +24 -25
- package/src/models/STInvoice.ts +34 -34
- package/src/models/STPackage.ts +143 -136
- package/src/models/STPendingInvoice.ts +26 -26
- package/src/models/StripeAccount.ts +27 -27
- package/src/models/StripeCheckoutSession.ts +10 -10
- package/src/models/StripePaymentIntent.ts +10 -10
- package/src/models/Ticket.ts +51 -52
- package/src/models/Token.test.ts +13 -13
- package/src/models/Token.ts +64 -63
- package/src/models/UsedRegisterCode.ts +20 -21
- package/src/models/User.ts +148 -144
- package/src/models/UserPermissions.ts +25 -28
- package/src/models/Webshop.ts +53 -53
- package/src/models/WebshopDiscountCode.ts +33 -33
- package/src/models/addresses/City.ts +12 -12
- package/src/models/addresses/PostalCode.test.ts +68 -69
- package/src/models/addresses/PostalCode.ts +57 -57
- package/src/models/addresses/Province.ts +8 -8
- package/src/models/addresses/Street.ts +10 -12
- package/src/models/index.ts +54 -55
- package/src/structures/OrganizationServerMetaData.ts +36 -36
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { column, Model } from
|
|
2
|
-
import { SimpleError } from
|
|
3
|
-
import { I18n } from
|
|
4
|
-
import { EmailTemplateType, Recipient, Replacement } from
|
|
5
|
-
import basex from
|
|
6
|
-
import crypto from
|
|
7
|
-
import { v4 as uuidv4 } from
|
|
8
|
-
import { sendEmailTemplate } from
|
|
9
|
-
import { Platform } from
|
|
10
|
-
|
|
11
|
-
const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
|
12
|
-
const bs58 = basex(ALPHABET)
|
|
1
|
+
import { column, Model } from '@simonbackx/simple-database';
|
|
2
|
+
import { SimpleError } from '@simonbackx/simple-errors';
|
|
3
|
+
import { I18n } from '@stamhoofd/backend-i18n';
|
|
4
|
+
import { EmailTemplateType, Recipient, Replacement } from '@stamhoofd/structures';
|
|
5
|
+
import basex from 'base-x';
|
|
6
|
+
import crypto from 'crypto';
|
|
7
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
8
|
+
import { sendEmailTemplate } from '../helpers/EmailBuilder';
|
|
9
|
+
import { Platform } from './Platform';
|
|
10
|
+
|
|
11
|
+
const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
12
|
+
const bs58 = basex(ALPHABET);
|
|
13
13
|
|
|
14
14
|
async function randomBytes(size: number): Promise<Buffer> {
|
|
15
15
|
return new Promise((resolve, reject) => {
|
|
@@ -30,79 +30,78 @@ async function randomInt(max: number): Promise<number> {
|
|
|
30
30
|
reject(err);
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
resolve(n)
|
|
34
|
-
})
|
|
35
|
-
})
|
|
33
|
+
resolve(n);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
38
|
/**
|
|
40
39
|
* Holds the verificationCodes for a given email (not a user, since a user can switch email addresses and might avoid verification that way)
|
|
41
40
|
*/
|
|
42
41
|
export class EmailVerificationCode extends Model {
|
|
43
|
-
static table =
|
|
42
|
+
static table = 'email_verification_codes';
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
primary: true, type:
|
|
44
|
+
@column({
|
|
45
|
+
primary: true, type: 'string', beforeSave(value) {
|
|
47
46
|
return value ?? uuidv4();
|
|
48
|
-
}
|
|
47
|
+
},
|
|
49
48
|
})
|
|
50
49
|
id!: string;
|
|
51
50
|
|
|
52
|
-
@column({ type:
|
|
53
|
-
organizationId: string|null = null;
|
|
51
|
+
@column({ type: 'string', nullable: true })
|
|
52
|
+
organizationId: string | null = null;
|
|
54
53
|
|
|
55
|
-
@column({ type:
|
|
54
|
+
@column({ type: 'string' })
|
|
56
55
|
userId: string;
|
|
57
56
|
|
|
58
57
|
/**
|
|
59
58
|
* The e-mail that will get verified. If on verification, the user e-mail differs from this one,
|
|
60
59
|
* we'll set the user email to this email address
|
|
61
60
|
*/
|
|
62
|
-
@column({ type:
|
|
61
|
+
@column({ type: 'string' })
|
|
63
62
|
email: string;
|
|
64
63
|
|
|
65
64
|
/**
|
|
66
65
|
* This one is send to the sender. Allows for polling + extra length + sender authentication
|
|
67
66
|
*/
|
|
68
|
-
@column({ type:
|
|
69
|
-
token =
|
|
67
|
+
@column({ type: 'string' })
|
|
68
|
+
token = '';
|
|
70
69
|
|
|
71
|
-
@column({ type:
|
|
72
|
-
code =
|
|
70
|
+
@column({ type: 'string' })
|
|
71
|
+
code = '';
|
|
73
72
|
|
|
74
73
|
/**
|
|
75
74
|
* The amount of times this code has been generated for the same e-mail address
|
|
76
75
|
*/
|
|
77
|
-
@column({ type:
|
|
76
|
+
@column({ type: 'integer' })
|
|
78
77
|
generatedCount = 0;
|
|
79
78
|
|
|
80
79
|
/**
|
|
81
80
|
* The amount of times this unique code has been tried.
|
|
82
81
|
*/
|
|
83
|
-
@column({ type:
|
|
82
|
+
@column({ type: 'integer' })
|
|
84
83
|
tries = 0;
|
|
85
84
|
|
|
86
|
-
@column({ type:
|
|
85
|
+
@column({ type: 'datetime' })
|
|
87
86
|
expiresAt: Date;
|
|
88
87
|
|
|
89
88
|
/**
|
|
90
89
|
* createdAt behaves more like createdAt for verificationCode. Since every save is considered to have a new verificationCode
|
|
91
90
|
*/
|
|
92
91
|
@column({
|
|
93
|
-
type:
|
|
94
|
-
const date = new Date()
|
|
95
|
-
date.setMilliseconds(0)
|
|
96
|
-
return date
|
|
97
|
-
}
|
|
92
|
+
type: 'datetime', beforeSave() {
|
|
93
|
+
const date = new Date();
|
|
94
|
+
date.setMilliseconds(0);
|
|
95
|
+
return date;
|
|
96
|
+
},
|
|
98
97
|
})
|
|
99
|
-
createdAt: Date
|
|
98
|
+
createdAt: Date;
|
|
100
99
|
|
|
101
|
-
static CODE_LENGTH = 6
|
|
102
|
-
static MAX_TRIES = 9 // minus 0..MAX_TRIES_VARY
|
|
100
|
+
static CODE_LENGTH = 6;
|
|
101
|
+
static MAX_TRIES = 9; // minus 0..MAX_TRIES_VARY
|
|
103
102
|
|
|
104
103
|
async generateCode() {
|
|
105
|
-
this.code = ((await randomInt(Math.pow(10, EmailVerificationCode.CODE_LENGTH)))+
|
|
104
|
+
this.code = ((await randomInt(Math.pow(10, EmailVerificationCode.CODE_LENGTH))) + '').padStart(EmailVerificationCode.CODE_LENGTH, '0');
|
|
106
105
|
this.token = bs58.encode(await randomBytes(100)).toLowerCase();
|
|
107
106
|
|
|
108
107
|
// Increase generatedCount if we changed the code
|
|
@@ -112,64 +111,65 @@ export class EmailVerificationCode extends Model {
|
|
|
112
111
|
}
|
|
113
112
|
|
|
114
113
|
// Reset the real tries
|
|
115
|
-
this.tries = 0
|
|
114
|
+
this.tries = 0;
|
|
116
115
|
|
|
117
116
|
// Expire in 12 hours
|
|
118
|
-
this.expiresAt = new Date(new Date().getTime() + 1000 * 60 * 60 * 12)
|
|
117
|
+
this.expiresAt = new Date(new Date().getTime() + 1000 * 60 * 60 * 12);
|
|
119
118
|
}
|
|
120
119
|
|
|
121
|
-
getEmailVerificationUrl(user: import('./User').User, organization: import('./Organization').Organization|null, i18n: I18n) {
|
|
120
|
+
getEmailVerificationUrl(user: import('./User').User, organization: import('./Organization').Organization | null, i18n: I18n) {
|
|
122
121
|
let host: string;
|
|
123
122
|
if (user.permissions || !organization || STAMHOOFD.userMode === 'platform') {
|
|
124
|
-
host =
|
|
125
|
-
}
|
|
123
|
+
host = 'https://' + (STAMHOOFD.domains.dashboard ?? 'stamhoofd.app') + '/' + i18n.locale;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
126
|
// Add language if different than default
|
|
127
|
-
host =
|
|
127
|
+
host = 'https://' + organization.getHost();
|
|
128
128
|
|
|
129
|
-
if (i18n.language
|
|
130
|
-
host +=
|
|
129
|
+
if (i18n.language !== organization.i18n.language) {
|
|
130
|
+
host += '/' + i18n.language;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
return host+
|
|
134
|
+
return host + '/verify-email' + (user.organizationPermissions && this.organizationId ? '/' + encodeURIComponent(this.organizationId) : '') + '?code=' + encodeURIComponent(this.code) + '&token=' + encodeURIComponent(this.token);
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
138
|
* Return true if this token is still valid (used for automatic polling in code view)
|
|
139
139
|
*/
|
|
140
|
-
static async poll(organizationId: string|null, token: string): Promise<boolean> {
|
|
141
|
-
const verificationCodes = await this.where({
|
|
142
|
-
token,
|
|
140
|
+
static async poll(organizationId: string | null, token: string): Promise<boolean> {
|
|
141
|
+
const verificationCodes = await this.where({
|
|
142
|
+
token,
|
|
143
143
|
organizationId: {
|
|
144
144
|
sign: 'IN',
|
|
145
|
-
value: [organizationId, null]
|
|
146
|
-
}
|
|
147
|
-
}, { limit: 1 })
|
|
145
|
+
value: [organizationId, null],
|
|
146
|
+
},
|
|
147
|
+
}, { limit: 1 });
|
|
148
148
|
|
|
149
149
|
if (verificationCodes.length == 0) {
|
|
150
|
-
return false // = expired or invalid
|
|
150
|
+
return false; // = expired or invalid
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
const verificationCode = verificationCodes[0]
|
|
153
|
+
const verificationCode = verificationCodes[0];
|
|
154
154
|
|
|
155
155
|
if (verificationCode.token !== token) {
|
|
156
156
|
// Safety check, is not possible
|
|
157
|
-
console.error(
|
|
157
|
+
console.error('Security check failed for verify: check MySQL optimization');
|
|
158
158
|
return false;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
if (verificationCode.expiresAt < new Date()) {
|
|
162
|
-
// Expired.
|
|
162
|
+
// Expired.
|
|
163
163
|
// Can't expose this because that would expose a user enumeration attack
|
|
164
164
|
// -> we'll include this expiry date in e-mails
|
|
165
|
-
return false
|
|
165
|
+
return false;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
if (verificationCode.tries >= EmailVerificationCode.MAX_TRIES) {
|
|
169
|
-
return false
|
|
169
|
+
return false;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
return true
|
|
172
|
+
return true;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
/**
|
|
@@ -177,73 +177,73 @@ export class EmailVerificationCode extends Model {
|
|
|
177
177
|
* We just expose if it is valid or not, nothing else
|
|
178
178
|
* False = expired or invalid
|
|
179
179
|
* Error => token okay, but too many attempts checking the code
|
|
180
|
-
*
|
|
180
|
+
*
|
|
181
181
|
*/
|
|
182
|
-
static async verify(organizationId: string|null, token: string, code: string): Promise<EmailVerificationCode | undefined> {
|
|
183
|
-
if (code.length
|
|
184
|
-
return
|
|
182
|
+
static async verify(organizationId: string | null, token: string, code: string): Promise<EmailVerificationCode | undefined> {
|
|
183
|
+
if (code.length !== EmailVerificationCode.CODE_LENGTH) {
|
|
184
|
+
return;
|
|
185
185
|
}
|
|
186
|
-
|
|
187
|
-
const verificationCodes = await this.where({
|
|
188
|
-
token,
|
|
186
|
+
|
|
187
|
+
const verificationCodes = await this.where({
|
|
188
|
+
token,
|
|
189
189
|
organizationId: {
|
|
190
190
|
sign: 'IN',
|
|
191
|
-
value: [organizationId, null]
|
|
192
|
-
}
|
|
193
|
-
}, { limit: 1 })
|
|
191
|
+
value: [organizationId, null],
|
|
192
|
+
},
|
|
193
|
+
}, { limit: 1 });
|
|
194
194
|
|
|
195
195
|
if (verificationCodes.length == 0) {
|
|
196
|
-
return // = expired or invalid
|
|
196
|
+
return; // = expired or invalid
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
const verificationCode = verificationCodes[0]
|
|
199
|
+
const verificationCode = verificationCodes[0];
|
|
200
200
|
|
|
201
201
|
if (verificationCode.token !== token) {
|
|
202
202
|
// Safety check, is not possible
|
|
203
|
-
console.error(
|
|
203
|
+
console.error('Security check failed for verify: check MySQL optimization');
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
if (verificationCode.expiresAt < new Date()) {
|
|
208
|
-
// Expired.
|
|
208
|
+
// Expired.
|
|
209
209
|
// Can't expose this because that would expose a user enumeration attack
|
|
210
210
|
// -> we'll include this expiry date in e-mails
|
|
211
|
-
return
|
|
211
|
+
return;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
if (verificationCode.tries >= EmailVerificationCode.MAX_TRIES) {
|
|
215
215
|
// We can saferly inform the user, because he is authenticated with the token
|
|
216
216
|
throw new SimpleError({
|
|
217
|
-
code:
|
|
218
|
-
message:
|
|
219
|
-
human:
|
|
220
|
-
statusCode: 429
|
|
221
|
-
})
|
|
217
|
+
code: 'too_many_attempts',
|
|
218
|
+
message: 'Too many attempts',
|
|
219
|
+
human: 'Je hebt de code te veel foutief ingegeven. Verstuur eerst een nieuwe code voor je opnieuw probeert.',
|
|
220
|
+
statusCode: 429,
|
|
221
|
+
});
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
if (verificationCode.code === code || (code ===
|
|
224
|
+
if (verificationCode.code === code || (code === '111111' && STAMHOOFD.environment === 'development')) {
|
|
225
225
|
// Delete all remaining information!
|
|
226
226
|
// To avoid leaving information about the existince of this user (tries)
|
|
227
|
-
await verificationCode.delete()
|
|
227
|
+
await verificationCode.delete();
|
|
228
228
|
|
|
229
|
-
return verificationCode
|
|
229
|
+
return verificationCode;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
verificationCode.tries
|
|
233
|
-
await verificationCode.save()
|
|
232
|
+
verificationCode.tries++;
|
|
233
|
+
await verificationCode.save();
|
|
234
234
|
|
|
235
235
|
if (verificationCode.tries >= EmailVerificationCode.MAX_TRIES) {
|
|
236
236
|
// We can saferly inform the user, because he is authenticated with the token
|
|
237
237
|
throw new SimpleError({
|
|
238
|
-
code:
|
|
239
|
-
message:
|
|
240
|
-
human:
|
|
241
|
-
statusCode: 429
|
|
242
|
-
})
|
|
238
|
+
code: 'too_many_attempts',
|
|
239
|
+
message: 'Too many attempts',
|
|
240
|
+
human: 'Je hebt de code te veel foutief ingegeven. Verstuur eerst een nieuwe code voor je opnieuw probeert.',
|
|
241
|
+
statusCode: 429,
|
|
242
|
+
});
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
async send(user: import('./User').User, organization: import('./Organization').Organization|null, i18n: I18n, withCode = true) {
|
|
246
|
+
async send(user: import('./User').User, organization: import('./Organization').Organization | null, i18n: I18n, withCode = true) {
|
|
247
247
|
const url = this.getEmailVerificationUrl(user, organization, i18n);
|
|
248
248
|
|
|
249
249
|
const name = organization?.name ?? (await Platform.getSharedPrivateStruct()).config.name;
|
|
@@ -251,16 +251,16 @@ export class EmailVerificationCode extends Model {
|
|
|
251
251
|
const replacements: Replacement[] = [
|
|
252
252
|
Replacement.create({
|
|
253
253
|
token: 'organizationName',
|
|
254
|
-
value: name
|
|
254
|
+
value: name,
|
|
255
255
|
}),
|
|
256
256
|
Replacement.create({
|
|
257
257
|
token: 'confirmEmailUrl',
|
|
258
|
-
value: url
|
|
259
|
-
})
|
|
260
|
-
]
|
|
258
|
+
value: url,
|
|
259
|
+
}),
|
|
260
|
+
];
|
|
261
261
|
|
|
262
262
|
if (withCode) {
|
|
263
|
-
const formattedCode = this.code.substr(0, 3)+
|
|
263
|
+
const formattedCode = this.code.substr(0, 3) + ' ' + this.code.substr(3);
|
|
264
264
|
|
|
265
265
|
await sendEmailTemplate(organization, {
|
|
266
266
|
recipients: [
|
|
@@ -270,66 +270,69 @@ export class EmailVerificationCode extends Model {
|
|
|
270
270
|
...replacements,
|
|
271
271
|
Replacement.create({
|
|
272
272
|
token: 'confirmEmailCode',
|
|
273
|
-
value: formattedCode
|
|
274
|
-
})
|
|
275
|
-
]
|
|
276
|
-
})
|
|
273
|
+
value: formattedCode,
|
|
274
|
+
}),
|
|
275
|
+
],
|
|
276
|
+
}),
|
|
277
277
|
],
|
|
278
278
|
template: {
|
|
279
279
|
type: EmailTemplateType.VerifyEmail,
|
|
280
280
|
},
|
|
281
|
-
type: 'transactional'
|
|
282
|
-
})
|
|
283
|
-
}
|
|
281
|
+
type: 'transactional',
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
284
285
|
await sendEmailTemplate(organization, {
|
|
285
286
|
recipients: [
|
|
286
287
|
Recipient.create({
|
|
287
288
|
email: this.email,
|
|
288
|
-
replacements
|
|
289
|
-
})
|
|
289
|
+
replacements,
|
|
290
|
+
}),
|
|
290
291
|
],
|
|
291
292
|
template: {
|
|
292
293
|
type: EmailTemplateType.VerifyEmailWithoutCode,
|
|
293
294
|
},
|
|
294
|
-
type: 'transactional'
|
|
295
|
-
})
|
|
295
|
+
type: 'transactional',
|
|
296
|
+
});
|
|
296
297
|
}
|
|
297
298
|
}
|
|
298
299
|
|
|
299
|
-
static async resend(organization: import('./Organization').Organization|null, token: string, i18n: I18n) {
|
|
300
|
-
const verificationCodes = await this.where({
|
|
301
|
-
token,
|
|
302
|
-
organizationId: organization
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
300
|
+
static async resend(organization: import('./Organization').Organization | null, token: string, i18n: I18n) {
|
|
301
|
+
const verificationCodes = await this.where({
|
|
302
|
+
token,
|
|
303
|
+
organizationId: organization
|
|
304
|
+
? {
|
|
305
|
+
sign: 'IN',
|
|
306
|
+
value: [organization.id, null],
|
|
307
|
+
}
|
|
308
|
+
: null,
|
|
309
|
+
}, { limit: 1 });
|
|
307
310
|
|
|
308
311
|
if (verificationCodes.length == 0) {
|
|
309
|
-
console.log("Can't resend code, no coded found for token", token)
|
|
312
|
+
console.log("Can't resend code, no coded found for token", token);
|
|
310
313
|
// TODO: maybe send a note via email
|
|
311
|
-
return
|
|
314
|
+
return;
|
|
312
315
|
}
|
|
313
316
|
|
|
314
|
-
const verificationCode = verificationCodes[0]
|
|
317
|
+
const verificationCode = verificationCodes[0];
|
|
315
318
|
|
|
316
319
|
if (verificationCode.expiresAt < new Date()) {
|
|
317
320
|
// Don't report error, could be brute forced
|
|
318
|
-
console.log("Can't resend code, token is expired", token)
|
|
319
|
-
return
|
|
321
|
+
console.log("Can't resend code, token is expired", token);
|
|
322
|
+
return;
|
|
320
323
|
}
|
|
321
324
|
|
|
322
|
-
const {User} = await import('./User')
|
|
323
|
-
const user = await User.getByID(verificationCode.userId)
|
|
325
|
+
const { User } = await import('./User');
|
|
326
|
+
const user = await User.getByID(verificationCode.userId);
|
|
324
327
|
if (!user) {
|
|
325
|
-
return
|
|
328
|
+
return;
|
|
326
329
|
}
|
|
327
|
-
await verificationCode.send(user, organization, i18n)
|
|
330
|
+
await verificationCode.send(user, organization, i18n);
|
|
328
331
|
}
|
|
329
332
|
|
|
330
333
|
/**
|
|
331
334
|
* Create or reuse a verification code for a given email address
|
|
332
|
-
* If needed, it will update the code.
|
|
335
|
+
* If needed, it will update the code.
|
|
333
336
|
* Use this method for sending only, not for verification!
|
|
334
337
|
*/
|
|
335
338
|
static async createFor(user: import('./User').User, email: string): Promise<EmailVerificationCode> {
|
|
@@ -340,32 +343,33 @@ export class EmailVerificationCode extends Model {
|
|
|
340
343
|
// Since, when changing email, we don't throw an error if it is use (user enumeration)
|
|
341
344
|
// So multiple users should be able to request changing to a password, but only on validation should they fail
|
|
342
345
|
// (or this should be noted in the verification email and accounts could be merged)
|
|
343
|
-
const verificationCodes = await this.where({ userId: user.id }, { limit: 1 })
|
|
346
|
+
const verificationCodes = await this.where({ userId: user.id }, { limit: 1 });
|
|
344
347
|
|
|
345
|
-
let verificationCode: EmailVerificationCode
|
|
348
|
+
let verificationCode: EmailVerificationCode;
|
|
346
349
|
if (verificationCodes.length == 0) {
|
|
347
|
-
verificationCode = new EmailVerificationCode()
|
|
348
|
-
verificationCode.organizationId = user.organizationId
|
|
349
|
-
await verificationCode.generateCode()
|
|
350
|
+
verificationCode = new EmailVerificationCode();
|
|
351
|
+
verificationCode.organizationId = user.organizationId;
|
|
352
|
+
await verificationCode.generateCode();
|
|
350
353
|
|
|
351
354
|
// Reset the real tries
|
|
352
|
-
verificationCode.tries = 0
|
|
355
|
+
verificationCode.tries = 0;
|
|
353
356
|
|
|
354
357
|
// Expire in 3 hours
|
|
355
|
-
verificationCode.expiresAt = new Date(new Date().getTime() + 1000 * 60 * 60 * 3)
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
+
verificationCode.expiresAt = new Date(new Date().getTime() + 1000 * 60 * 60 * 3);
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
verificationCode = verificationCodes[0];
|
|
358
362
|
|
|
359
363
|
if (verificationCode.expiresAt < new Date(new Date().getTime() - 15 * 60 * 1000) || verificationCode.tries >= EmailVerificationCode.MAX_TRIES) {
|
|
360
364
|
// Expired: also update the token
|
|
361
|
-
await verificationCode.generateCode()
|
|
365
|
+
await verificationCode.generateCode();
|
|
362
366
|
}
|
|
363
367
|
}
|
|
364
|
-
|
|
365
|
-
verificationCode.email = email
|
|
366
|
-
verificationCode.userId = user.id
|
|
367
368
|
|
|
368
|
-
|
|
369
|
-
|
|
369
|
+
verificationCode.email = email;
|
|
370
|
+
verificationCode.userId = user.id;
|
|
371
|
+
|
|
372
|
+
await verificationCode.save();
|
|
373
|
+
return verificationCode;
|
|
370
374
|
}
|
|
371
375
|
}
|
package/src/models/Event.ts
CHANGED
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
import { column, Model } from "@simonbackx/simple-database";
|
|
1
|
+
import { column, Model } from '@simonbackx/simple-database';
|
|
3
2
|
import { EventMeta, Event as EventStruct, GroupType } from '@stamhoofd/structures';
|
|
4
|
-
import { v4 as uuidv4 } from
|
|
5
|
-
import { Group } from
|
|
3
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
+
import { Group } from './Group';
|
|
6
5
|
|
|
7
6
|
export class Event extends Model {
|
|
8
|
-
static table =
|
|
7
|
+
static table = 'events';
|
|
9
8
|
|
|
10
|
-
@column({ primary: true, type:
|
|
9
|
+
@column({ primary: true, type: 'string', beforeSave(value) {
|
|
11
10
|
return value ?? uuidv4();
|
|
12
11
|
} })
|
|
13
12
|
id!: string;
|
|
14
13
|
|
|
15
|
-
@column({ type:
|
|
16
|
-
name: string
|
|
14
|
+
@column({ type: 'string' })
|
|
15
|
+
name: string;
|
|
17
16
|
|
|
18
|
-
@column({ type:
|
|
19
|
-
typeId: string
|
|
17
|
+
@column({ type: 'string' })
|
|
18
|
+
typeId: string;
|
|
20
19
|
|
|
21
|
-
@column({ type:
|
|
22
|
-
organizationId: string|null = null
|
|
20
|
+
@column({ type: 'string', nullable: true })
|
|
21
|
+
organizationId: string | null = null;
|
|
23
22
|
|
|
24
|
-
@column({ type:
|
|
25
|
-
groupId: string|null = null
|
|
23
|
+
@column({ type: 'string', nullable: true })
|
|
24
|
+
groupId: string | null = null;
|
|
26
25
|
|
|
27
|
-
@column({ type:
|
|
28
|
-
startDate: Date
|
|
26
|
+
@column({ type: 'datetime' })
|
|
27
|
+
startDate: Date;
|
|
29
28
|
|
|
30
|
-
@column({ type:
|
|
31
|
-
endDate: Date
|
|
29
|
+
@column({ type: 'datetime' })
|
|
30
|
+
endDate: Date;
|
|
32
31
|
|
|
33
|
-
@column({ type:
|
|
34
|
-
meta = EventMeta.create({})
|
|
32
|
+
@column({ type: 'json', decoder: EventMeta })
|
|
33
|
+
meta = EventMeta.create({});
|
|
35
34
|
|
|
36
35
|
@column({
|
|
37
|
-
type:
|
|
36
|
+
type: 'datetime', beforeSave(old?: any) {
|
|
38
37
|
if (old !== undefined) {
|
|
39
38
|
return old;
|
|
40
39
|
}
|
|
41
|
-
const date = new Date()
|
|
42
|
-
date.setMilliseconds(0)
|
|
43
|
-
return date
|
|
44
|
-
}
|
|
40
|
+
const date = new Date();
|
|
41
|
+
date.setMilliseconds(0);
|
|
42
|
+
return date;
|
|
43
|
+
},
|
|
45
44
|
})
|
|
46
|
-
createdAt: Date
|
|
45
|
+
createdAt: Date;
|
|
47
46
|
|
|
48
47
|
@column({
|
|
49
|
-
type:
|
|
50
|
-
const date = new Date()
|
|
51
|
-
date.setMilliseconds(0)
|
|
52
|
-
return date
|
|
48
|
+
type: 'datetime', beforeSave() {
|
|
49
|
+
const date = new Date();
|
|
50
|
+
date.setMilliseconds(0);
|
|
51
|
+
return date;
|
|
53
52
|
},
|
|
54
|
-
skipUpdate: true
|
|
53
|
+
skipUpdate: true,
|
|
55
54
|
})
|
|
56
|
-
updatedAt: Date
|
|
55
|
+
updatedAt: Date;
|
|
57
56
|
|
|
58
57
|
/**
|
|
59
58
|
* @deprecated
|
|
60
59
|
*/
|
|
61
|
-
getStructure(group?: Group|null) {
|
|
60
|
+
getStructure(group?: Group | null) {
|
|
62
61
|
return EventStruct.create({
|
|
63
62
|
...this,
|
|
64
|
-
group: group ? group.getStructure() : null
|
|
65
|
-
})
|
|
63
|
+
group: group ? group.getStructure() : null,
|
|
64
|
+
});
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
/**
|
|
69
68
|
* @deprecated
|
|
70
69
|
*/
|
|
71
|
-
getPrivateStructure(group?: Group|null) {
|
|
70
|
+
getPrivateStructure(group?: Group | null) {
|
|
72
71
|
return EventStruct.create({
|
|
73
72
|
...this,
|
|
74
|
-
group: group ? group.getPrivateStructure() : null
|
|
75
|
-
})
|
|
73
|
+
group: group ? group.getPrivateStructure() : null,
|
|
74
|
+
});
|
|
76
75
|
}
|
|
77
76
|
|
|
78
|
-
async syncGroupRequirements(group: Group|null) {
|
|
77
|
+
async syncGroupRequirements(group: Group | null) {
|
|
79
78
|
if (!group) {
|
|
80
79
|
return;
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
group.settings.requireDefaultAgeGroupIds = this.meta.defaultAgeGroupIds ?? []
|
|
84
|
-
group.settings.requireGroupIds = this.meta.groups?.map(g => g.id) ?? []
|
|
82
|
+
group.settings.requireDefaultAgeGroupIds = this.meta.defaultAgeGroupIds ?? [];
|
|
83
|
+
group.settings.requireGroupIds = this.meta.groups?.map(g => g.id) ?? [];
|
|
85
84
|
|
|
86
85
|
if (group.type === GroupType.EventRegistration) {
|
|
87
86
|
// Don't change the name of the waiting list
|
|
88
|
-
group.settings.name = this.name
|
|
87
|
+
group.settings.name = this.name;
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
if (this.organizationId) {
|
|
92
91
|
// This is a not-national event, so require the organization
|
|
93
|
-
group.settings.requireOrganizationIds = [this.organizationId]
|
|
94
|
-
group.settings.requireOrganizationTags = []
|
|
95
|
-
group.settings.requirePlatformMembershipOn = null
|
|
96
|
-
}
|
|
97
|
-
|
|
92
|
+
group.settings.requireOrganizationIds = [this.organizationId];
|
|
93
|
+
group.settings.requireOrganizationTags = [];
|
|
94
|
+
group.settings.requirePlatformMembershipOn = null;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
group.settings.requireOrganizationTags = this.meta.organizationTagIds ?? [];
|
|
98
98
|
|
|
99
99
|
// Everyone can register
|
|
100
|
-
group.settings.requireOrganizationIds = []
|
|
100
|
+
group.settings.requireOrganizationIds = [];
|
|
101
101
|
|
|
102
102
|
// But they need a valid platform membership
|
|
103
|
-
group.settings.requirePlatformMembershipOn = this.endDate
|
|
103
|
+
group.settings.requirePlatformMembershipOn = this.endDate;
|
|
104
104
|
}
|
|
105
|
-
await group.save()
|
|
105
|
+
await group.save();
|
|
106
106
|
|
|
107
107
|
if (group.waitingListId) {
|
|
108
|
-
const waitingList = await Group.getByID(group.waitingListId)
|
|
108
|
+
const waitingList = await Group.getByID(group.waitingListId);
|
|
109
109
|
if (waitingList) {
|
|
110
110
|
if (group.settings.allowRegistrationsByOrganization) {
|
|
111
|
-
waitingList.settings.allowRegistrationsByOrganization = true
|
|
111
|
+
waitingList.settings.allowRegistrationsByOrganization = true;
|
|
112
112
|
}
|
|
113
|
-
await this.syncGroupRequirements(waitingList)
|
|
113
|
+
await this.syncGroupRequirements(waitingList);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
}
|