1
0
Fork 0

wip(org): Work on signup flow

This commit is contained in:
joostdecock 2023-01-14 22:40:07 +01:00
parent 378df4b156
commit fe568b6a16
16 changed files with 407 additions and 33 deletions

View file

@ -147,6 +147,7 @@ UserModel.prototype.guardedCreate = async function ({ body }) {
return this.setResponse(400, 'unsupportedLanguage')
const ehash = hash(clean(body.email))
const check = randomString()
await this.read({ ehash })
if (this.exists) {
/*
@ -176,6 +177,7 @@ UserModel.prototype.guardedCreate = async function ({ body }) {
email: this.clear.email,
id: this.record.id,
ehash: ehash,
check,
},
userId: this.record.id,
})
@ -189,7 +191,7 @@ UserModel.prototype.guardedCreate = async function ({ body }) {
actionUrl:
type === 'signup-aed'
? false // No actionUrl for disabled accounts
: i18nUrl(body.language, `/confirm/${type}/${this.Confirmation.record.id}`),
: i18nUrl(body.language, `/confirm/${type}/${this.Confirmation.record.id}/${check}`),
whyUrl: i18nUrl(body.language, `/docs/faq/email/why-${type}`),
supportUrl: i18nUrl(body.language, `/patrons/join`),
},
@ -247,9 +249,11 @@ UserModel.prototype.guardedCreate = async function ({ body }) {
email: this.clear.email,
id: this.record.id,
ehash: ehash,
check,
},
userId: this.record.id,
})
console.log(check)
// Send signup email
if (!this.isUnitTest(body) || this.config.tests.sendEmail)
@ -258,7 +262,10 @@ UserModel.prototype.guardedCreate = async function ({ body }) {
language: this.language,
to: this.clear.email,
replacements: {
actionUrl: i18nUrl(this.language, `/confirm/signup/${this.Confirmation.record.id}`),
actionUrl: i18nUrl(
this.language,
`/confirm/signup/${this.Confirmation.record.id}/${check}`
),
whyUrl: i18nUrl(this.language, `/docs/faq/email/why-signup`),
supportUrl: i18nUrl(this.language, `/patrons/join`),
},