add redeemCode on register process for createUser

This commit is contained in:
ogerly 2022-03-21 10:54:56 +01:00
parent 3992882962
commit 15e0186381
4 changed files with 12 additions and 3 deletions

View File

@ -367,11 +367,15 @@ export class UserResolver {
// TODO: this has duplicate code with sendResetPasswordEmail
const emailOptIn = await createEmailOptIn(dbUser.id, queryRunner)
const activationLink = CONFIG.EMAIL_LINK_VERIFICATION.replace(
let activationLink = CONFIG.EMAIL_LINK_VERIFICATION.replace(
/{code}/g,
emailOptIn.verificationCode.toString(),
)
if (redeemCode !== '') {
activationLink += '/' + redeemCode
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const emailSent = await sendAccountActivationEmail({
link: activationLink,
@ -380,13 +384,13 @@ export class UserResolver {
email,
})
/* uncomment this, when you need the activation link on the console
// uncomment this, when you need the activation link on the console
// In case EMails are disabled log the activation link for the user
if (!emailSent) {
// eslint-disable-next-line no-console
console.log(`Account confirmation link: ${activationLink}`)
}
*/
await queryRunner.commitTransaction()
} catch (e) {
await queryRunner.rollbackTransaction()

View File

@ -45,6 +45,7 @@ export const createUser = gql`
$email: String!
$language: String!
$publisherId: Int
$redeemCode: String
) {
createUser(
email: $email
@ -52,6 +53,7 @@ export const createUser = gql`
lastName: $lastName
language: $language
publisherId: $publisherId
redeemCode: $redeemCode
) {
id
}

View File

@ -140,6 +140,7 @@ export const elopageWebhook = async (req: any, res: any): Promise<void> => {
firstName,
lastName,
publisherId: loginElopageBuy.publisherId || 0, // This seemed to be the default value if not set
redeemCode: '',
})
} catch (error) {
// eslint-disable-next-line no-console

View File

@ -45,6 +45,7 @@ export const createUser = gql`
$email: String!
$language: String!
$publisherId: Int
$redeemCode: String
) {
createUser(
email: $email
@ -52,6 +53,7 @@ export const createUser = gql`
lastName: $lastName
language: $language
publisherId: $publisherId
redeemCode: $redeemCode
) {
id
}