Skip to content

Commit

Permalink
fix: fix link for recovery email, remove unnecessary background url f…
Browse files Browse the repository at this point in the history
…rom sending server
  • Loading branch information
yaroslav-fedyshyn-nordwhale committed Oct 28, 2019
1 parent 8090447 commit 2dfdef3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
15 changes: 4 additions & 11 deletions src/server/mautic/mauticAPI.js
Expand Up @@ -47,15 +47,12 @@ export const Mautic = {
.split('')
.filter(c => c)
.join(' ')
const codeBackgroundImgUrl = `${Config.dappUrl}/MagicLinkBackgroundForEmail.png`

console.log('codeBackgroundImgUrl', codeBackgroundImgUrl)

return this.baseQuery(`/emails/${Config.mauticVerifyEmailId}/contact/${user.mauticId}/send`, this.baseHeaders, {
tokens: { code: codeWithSpaces, firstName: user.fullName, codeBackgroundImgUrl }
tokens: { code, firstName: user.fullName }
})
},
sendRecoveryEmail(user: UserRecord, mnemonic: string) {
sendRecoveryEmail(user: UserRecord, mnemonic: string, recoverPageUrl: string) {
if (!(mnemonic && user.fullName && user.mauticId && Config.mauticRecoveryEmailId))
throw new Error('missing input for sending recovery email')

Expand All @@ -69,19 +66,15 @@ export const Mautic = {
.join(' ')

return this.baseQuery(`/emails/${Config.mauticRecoveryEmailId}/contact/${user.mauticId}/send`, this.baseHeaders, {
tokens: { firstName: user.fullName, seedFirst: mnemonicFirstPart, seedSecond: mnemonicSecondPart }
tokens: { firstName: user.fullName, seedFirst: mnemonicFirstPart, seedSecond: mnemonicSecondPart, recoverPageUrl }
})
},
sendMagicLinkEmail(user: UserRecord, magicLink: string) {
if (!(magicLink && user.fullName && user.mauticId && Config.mauticmagicLinkEmailId))
throw new Error('missing input for sending magicLink email')

const codeBackgroundImgUrl = `${Config.dappUrl}/MagicLinkBackgroundForEmail.png`

console.log('codeBackgroundImgUrl2', codeBackgroundImgUrl)

return this.baseQuery(`/emails/${Config.mauticmagicLinkEmailId}/contact/${user.mauticId}/send`, this.baseHeaders, {
tokens: { link: magicLink, firstName: user.fullName, codeBackgroundImgUrl }
tokens: { link: magicLink, firstName: user.fullName }
})
}
}
5 changes: 3 additions & 2 deletions src/server/send/sendAPI.js
Expand Up @@ -77,10 +77,11 @@ const setup = (app: Router) => {
const log = req.log.child({ from: 'sendAPI - /send/recoveryinstructions' })
const { user } = req
const { mnemonic } = req.body
const recoverPageUrl = `${conf.walletUrl}/Auth/Recover`

log.info('sending recovery email', user)
//at this stage user record should contain all his details
await Mautic.sendRecoveryEmail(user, mnemonic)
await Mautic.sendRecoveryEmail(user, mnemonic, recoverPageUrl)
res.json({ ok: 1 })
})
)
Expand All @@ -98,7 +99,7 @@ const setup = (app: Router) => {
app.post(
'/send/magiclink',
passport.authenticate('jwt', { session: false }),
onlyInEnv('development', 'production', 'staging', 'test'),
onlyInEnv('production', 'staging', 'test'),
wrapAsync(async (req, res, next) => {
const log = req.log.child({ from: 'sendAPI - /send/magiclink' })
const { user } = req
Expand Down
8 changes: 1 addition & 7 deletions src/server/server.config.js
Expand Up @@ -203,7 +203,7 @@ const conf = convict({
doc: 'id of email template',
format: '*',
env: 'MAUTIC_VERIFY_ID',
default: '4'
default: '31'
},
zoomURL: {
doc: 'Zoom Client URL',
Expand Down Expand Up @@ -310,12 +310,6 @@ const conf = convict({
format: '*',
env: 'WEB3_SITE_URL',
default: undefined
},
dappUrl: {
doc: 'Dapp site url',
format: '*',
env: 'DAPP_URL',
default: undefined
}
})

Expand Down

0 comments on commit 2dfdef3

Please sign in to comment.