@stamhoofd/backend 2.30.4 → 2.30.5
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stamhoofd/backend",
|
|
3
|
-
"version": "2.30.
|
|
3
|
+
"version": "2.30.5",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"@simonbackx/simple-encoding": "2.15.1",
|
|
37
37
|
"@simonbackx/simple-endpoints": "1.14.0",
|
|
38
38
|
"@simonbackx/simple-logging": "^1.0.1",
|
|
39
|
-
"@stamhoofd/backend-i18n": "2.30.
|
|
40
|
-
"@stamhoofd/backend-middleware": "2.30.
|
|
41
|
-
"@stamhoofd/email": "2.30.
|
|
42
|
-
"@stamhoofd/models": "2.30.
|
|
43
|
-
"@stamhoofd/queues": "2.30.
|
|
44
|
-
"@stamhoofd/sql": "2.30.
|
|
45
|
-
"@stamhoofd/structures": "2.30.
|
|
46
|
-
"@stamhoofd/utility": "2.30.
|
|
39
|
+
"@stamhoofd/backend-i18n": "2.30.5",
|
|
40
|
+
"@stamhoofd/backend-middleware": "2.30.5",
|
|
41
|
+
"@stamhoofd/email": "2.30.5",
|
|
42
|
+
"@stamhoofd/models": "2.30.5",
|
|
43
|
+
"@stamhoofd/queues": "2.30.5",
|
|
44
|
+
"@stamhoofd/sql": "2.30.5",
|
|
45
|
+
"@stamhoofd/structures": "2.30.5",
|
|
46
|
+
"@stamhoofd/utility": "2.30.5",
|
|
47
47
|
"archiver": "^7.0.1",
|
|
48
48
|
"aws-sdk": "^2.885.0",
|
|
49
49
|
"axios": "1.6.8",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"postmark": "4.0.2",
|
|
61
61
|
"stripe": "^16.6.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "3ebcff6728ea5d54e9c65509a14ddb10cd52a4f2"
|
|
64
64
|
}
|
|
@@ -54,6 +54,8 @@ export class ForgotPasswordEndpoint extends Endpoint<Params, Query, Body, Respon
|
|
|
54
54
|
await sendEmailTemplate(organization, {
|
|
55
55
|
recipients: [
|
|
56
56
|
Recipient.create({
|
|
57
|
+
firstName: user.firstName,
|
|
58
|
+
lastName: user.lastName,
|
|
57
59
|
email: request.body.email,
|
|
58
60
|
replacements: [
|
|
59
61
|
Replacement.create({
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Decoder } from '@simonbackx/simple-encoding';
|
|
2
2
|
import { DecodedRequest, Endpoint, Request, Response } from "@simonbackx/simple-endpoints";
|
|
3
3
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { NewUser, SignupResponse } from "@stamhoofd/structures";
|
|
4
|
+
import { EmailVerificationCode, PasswordToken, sendEmailTemplate, User } from '@stamhoofd/models';
|
|
5
|
+
import { EmailTemplateType, NewUser, Recipient, Replacement, SignupResponse } from "@stamhoofd/structures";
|
|
7
6
|
|
|
8
7
|
import { Context } from '../../helpers/Context';
|
|
9
8
|
|
|
@@ -57,28 +56,37 @@ export class SignupEndpoint extends Endpoint<Params, Query, Body, ResponseBody>
|
|
|
57
56
|
user = u
|
|
58
57
|
|
|
59
58
|
if (u.hasAccount()) {
|
|
60
|
-
// Send an e-mail to say you already have an account + follow password forgot flow
|
|
61
|
-
const recoveryUrl = await PasswordToken.getPasswordRecoveryUrl(user, organization, request.i18n)
|
|
62
|
-
const { from, replyTo } = {
|
|
63
|
-
from: (user.permissions || !organization ? Email.getInternalEmailFor(request.i18n) : organization.getDefaultFrom(request.i18n)),
|
|
64
|
-
replyTo: undefined
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const footer = (!user.permissions && organization ? "\n\n—\n\nOnze ledenadministratie werkt via het Stamhoofd platform, op maat van verenigingen. Probeer het ook via https://"+request.i18n.localizedDomains.marketing()+"/ledenadministratie\n\n" : '')
|
|
68
|
-
|
|
69
|
-
const name = organization ? organization.name : 'Stamhoofd'
|
|
70
|
-
// Send email
|
|
71
|
-
Email.send({
|
|
72
|
-
from,
|
|
73
|
-
replyTo,
|
|
74
|
-
to: user.email,
|
|
75
|
-
subject: `[${name}] Je hebt al een account`,
|
|
76
|
-
type: "transactional",
|
|
77
|
-
text: (user.firstName ? "Hey "+user.firstName : "Hey") + ", \n\nJe probeerde een account aan te maken, maar je hebt eigenlijk al een account met e-mailadres "+user.email+". Als je jouw wachtwoord niet meer weet, kan je een nieuw wachtwoord instellen door op de volgende link te klikken of door deze te kopiëren in de adresbalk van jouw browser:\n"+recoveryUrl+"\n\nWachtwoord al teruggevonden of heb je helemaal niet proberen te registreren? Dan mag je deze e-mail veilig negeren.\n\nMet vriendelijke groeten,\n"+(user.permissions ? "Stamhoofd" : name)+footer
|
|
78
|
-
});
|
|
79
|
-
|
|
80
59
|
// Don't send the code
|
|
81
|
-
sendCode = false
|
|
60
|
+
sendCode = false;
|
|
61
|
+
|
|
62
|
+
// We don't await this block to avoid user enumeration attack using request response time
|
|
63
|
+
(async () => {
|
|
64
|
+
// Send an e-mail to say you already have an account + follow password forgot flow
|
|
65
|
+
const recoveryUrl = await PasswordToken.getPasswordRecoveryUrl(user, organization, request.i18n)
|
|
66
|
+
|
|
67
|
+
// Create e-mail builder
|
|
68
|
+
await sendEmailTemplate(organization, {
|
|
69
|
+
recipients: [
|
|
70
|
+
Recipient.create({
|
|
71
|
+
firstName: user.firstName,
|
|
72
|
+
lastName: user.lastName,
|
|
73
|
+
email: request.body.email,
|
|
74
|
+
replacements: [
|
|
75
|
+
Replacement.create({
|
|
76
|
+
token: 'resetUrl',
|
|
77
|
+
value: recoveryUrl
|
|
78
|
+
})
|
|
79
|
+
]
|
|
80
|
+
})
|
|
81
|
+
],
|
|
82
|
+
template: {
|
|
83
|
+
type: EmailTemplateType.SignupAlreadyHasAccount,
|
|
84
|
+
},
|
|
85
|
+
type: 'transactional'
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
})().catch(console.error);
|
|
89
|
+
|
|
82
90
|
} else {
|
|
83
91
|
// This is safe, because we are the first one. There is no password yet.
|
|
84
92
|
// If a hacker tries this, he won't be able to sign in, because he needs to
|
|
@@ -97,7 +105,7 @@ export class SignupEndpoint extends Endpoint<Params, Query, Body, ResponseBody>
|
|
|
97
105
|
const code = await EmailVerificationCode.createFor(user, user.email)
|
|
98
106
|
|
|
99
107
|
if (sendCode) {
|
|
100
|
-
code.send(user, organization, request.i18n)
|
|
108
|
+
code.send(user, organization, request.i18n).catch(console.error)
|
|
101
109
|
}
|
|
102
110
|
|
|
103
111
|
return new Response(SignupResponse.create({
|
|
@@ -108,7 +108,7 @@ export class PatchUserMembersEndpoint extends Endpoint<Params, Query, Body, Resp
|
|
|
108
108
|
})
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
const duplicate = await this.checkDuplicate(member, securityCode)
|
|
111
|
+
/*const duplicate = await this.checkDuplicate(member, securityCode)
|
|
112
112
|
if (duplicate) {
|
|
113
113
|
// Remove the member from the list
|
|
114
114
|
members.splice(members.findIndex(m => m.id === member.id), 1)
|
|
@@ -116,7 +116,7 @@ export class PatchUserMembersEndpoint extends Endpoint<Params, Query, Body, Resp
|
|
|
116
116
|
// Add new
|
|
117
117
|
addedMembers.push(duplicate)
|
|
118
118
|
continue
|
|
119
|
-
}
|
|
119
|
+
}*/
|
|
120
120
|
|
|
121
121
|
await member.save();
|
|
122
122
|
await MemberUserSyncer.onChangeMember(member)
|