Esempio n. 1
0
				prepareRender: (i) => {
					const rendered = mjml(i, mjmlRenderOptions);
					if (mjmlStrict && rendered.errors.length > 0) {
						// Intentionally logging both
						const message = `MJML validation errors encountered in template '${template}': ${rendered.errors.map(e => JSON.stringify(e)).join('\n')}`;
						log(WARN, message);
						// eslint-disable-next-line no-console
						console.warn(message);
					}
					return htmlFormat(rendered.html);
				},
Esempio n. 2
0
    User.register(newUser, req.body.password, (err, user) => {
      if (err) {
        if (err.code === 11000) {
          req.flash('error', 'A user with the given username is already registered')
        } else {
          console.log(err)
          req.flash('error', err.message)
          res.redirect("/admin/users/new");
        }
      } else if (req.body.sendUserDeails === 'yes') {
        const htmlOuput = mjml(`<mjml>
  <mj-body background-color="#ffffff" font-size="13px">
    <mj-section>
      <mj-column>
        <mj-text font-style="bold" font-size="24px" color="#626262" align="center">
Your account details
        </mj-text>
      </mj-column>
    </mj-section>
    <mj-divider border-color="#4f92ff" />
    <mj-wrapper padding-top="0">
      <mj-section padding-top="0">
        <mj-column>
          <mj-raw>
            <ul style="color: #4f92ff;">
              <li style="list-style:none;"><strong>Email:</strong> <span style="color: #000000;"> ${req.body.email}</span></li>
              <li style="list-style:none;"><strong>Username:</strong> <span style="color: #000000;"> ${req.body.username}</span></li>
              <li style="list-style:none;"><strong>Password:</strong> <span style="color: #000000;"> ${req.body.password}</span></li>
            </ul>
          </mj-raw>
        </mj-column>
      </mj-section>
            <mj-section>
        <mj-column>
          <mj-text>Note this is a temp password and you will have to change it once you activate your account</mj-text>
          <mj-text>If you did not request this account to be made or want your data removed.  Please click the delete button.</mj-text>
        </mj-column>
      </mj-section>
      <mj-section>
        <mj-column>
          <mj-button href="http://${req.headers.host}/user/activation" font-family="Helvetica" background-color="#4f92ff" color="white">
            Account Activation
          </mj-button>
        </mj-column>
        <mj-column>
          <mj-button href="http://${req.headers.host}/user/delete" font-family="Helvetica" background-color="#4f92ff" color="white">
            Delete Data
          </mj-button>
        </mj-column>
      </mj-section>
    </mj-wrapper>
  </mj-body>
</mjml>
`)
        const newUserDetailsEmail = {
          to: req.body.email,
          from: `${process.env.SITE_NAME} No-Reply <noreply@${process.env.EMAIL_DOMAIN}`,
          subject: `Here's your account details | ${process.env.SITE_NAME}`,
          html: htmlOuput.html
        }
        nodemailerSendGrid.sendMail(newUserDetailsEmail, function (err, info) {
          if (err) {
            console.log(err);
          } else {
            console.log(info);
            req.flash('success', `${req.body.username} Has been created! Sent details to user email.`);
            res.redirect("/admin/users");
          }
        })
      } else {
        req.flash('success', `${req.body.username} Has been created!`);
        res.redirect("/admin/users");
      }
    })