Use globals object in database rather than /_config/globals.json everywhere
[ndcode_site.git] / api / account / sign_up / send_email_verification_link.json.jst
index f4cb176..c682c2c 100644 (file)
@@ -2,7 +2,6 @@ let crypto = require('crypto')
 let XDate = require('xdate')
 
 return async env => {
-  let globals = await env.site.get_json('/_config/globals.json')
   let nodemailer_noreply = await env.site.get_nodemailer(
     '/_config/nodemailer_noreply.json'
   )
@@ -56,6 +55,11 @@ return async env => {
           {link_code, expires: expires.getTime()}
         )
 
+        let globals = await (await transaction.get({})).get('globals')
+        let site_url = await globals.get_json('site_url')
+        let noreply_from = await globals.get_json('noreply_from')
+        let noreply_signature = await globals.get_json('noreply_signature')
+
         let given_names = await account.get_json('given_names', '')
         let family_name = await account.get_json('family_name', '')
         let name =
@@ -63,7 +67,7 @@ return async env => {
 
         await nodemailer_noreply.sendMail(
           {
-            from: globals.noreply_from,
+            from: noreply_from,
             to: `${name} <${email}>`,
             subject: 'Email address verification',
             text: `Dear ${given_names},
@@ -71,12 +75,12 @@ return async env => {
 We have received a request to sign up using your email address.
 
 If this request is valid, please verify your email address by visiting the below link:
-${globals.site_url}/my_account/verify_email/index.html?email=${encodeURIComponent(email)}&link_code=${encodeURIComponent(link_code)}
+${site_url}/my_account/verify_email/index.html?email=${encodeURIComponent(email)}&link_code=${encodeURIComponent(link_code)}
 
 The link is valid for 24 hours.
 
 Thanks,
-${globals.noreply_signature}
+${noreply_signature}
 `
           }
         )