@@ -999,59 +999,63 @@ class User {
999999 sendReset ( resetKey , options , done ) {
10001000 // Send the invitation
10011001 const _this = this ;
1002- const subject = options . sitename + ': Reset password' ;
1003- const message = '<p>You are receiving this email because you asked for your password to be reset for the ' +
1004- options . sitename +
1005- ' site. If you did not ask for your password to be reset you can ignore this email.</p>\n\n' +
1006- // 'Your unique key: \n\n' +
1007- // '\t' + obj.key + '\n\n' +
1008- '<p>To reset your password follow the link below:</p>\n\n' +
1009- '<p>\t' +
1010- options . protocol +
1011- '://' +
1012- options . hostname +
1013- '/account/reset/' +
1014- this . ref +
1015- '/' +
1016- resetKey +
1017- '/</p>\n\n<p>' +
1018- options . email +
1019- '<br>\nvia the ' +
1020- options . sitename +
1021- ' site</p>' ;
1022- // HTML text
1023- let htmlText = '' ;
1024- const replacementsArray = [ ] ;
1025- replacementsArray . push ( [ '<!--PROTOCOL-->' , options . protocol ] ) ;
1026- replacementsArray . push ( [ '<!--HOST-->' , options . hostname ] ) ;
1027- replacementsArray . push ( [ '<!--SITENAME-->' , options . sitename ] ) ;
1028- replacementsArray . push ( [ '<!--TITLE-->' , subject ] ) ;
1029- replacementsArray . push ( [ '<!--BODY-->' , message ] ) ;
1030- replacementsArray . push ( [ '<!--EMAIL-->' , options . email ] ) ;
1031- replacementsArray . push ( [ '<!--CODA-->' , '' ] ) ;
1032- replacementsArray . push ( [
1033- '<p>' ,
1034- '<p style="margin-bottom: 10px; font-weight: normal; font: 13px/ 18px Arial, sans-serif; color: #000000;">'
1035- ] ) ;
1036- fs . readFile ( './templates/mail/default.html' , 'utf8' , ( err , f ) => {
1037- if ( err )
1038- debug ( err ) ;
1039- htmlText = f ;
1040- for ( let i = 0 ; i < replacementsArray . length ; i ++ ) {
1041- const re = new RegExp ( replacementsArray [ i ] [ 0 ] , 'gi' ) ;
1042- htmlText = htmlText . replace ( re , replacementsArray [ i ] [ 1 ] ) ;
1043- }
1044- // Plain text
1045- const plainText = h2p ( message ) ;
1046- const msg = {
1047- to : _this . email ,
1048- from : options . email ,
1049- subject : subject ,
1050- text : plainText ,
1051- html : htmlText
1052- } ;
1053- sendMail ( msg , options . hostname ) ;
1054- done ( null ) ;
1002+ settings . load ( options . appId , ( err , config ) => {
1003+ if ( err ) console . log ( err ) ;
1004+ const host = config . web_host || options . hostname ;
1005+ const subject = options . sitename + ': Reset password' ;
1006+ const message = '<p>You are receiving this email because you asked for your password to be reset for the ' +
1007+ options . sitename +
1008+ ' site. If you did not ask for your password to be reset you can ignore this email.</p>\n\n' +
1009+ // 'Your unique key: \n\n' +
1010+ // '\t' + obj.key + '\n\n' +
1011+ '<p>To reset your password follow the link below:</p>\n\n' +
1012+ '<p>\t' +
1013+ options . protocol +
1014+ '://' +
1015+ host +
1016+ '/account/reset/' +
1017+ this . ref +
1018+ '/' +
1019+ resetKey +
1020+ '/</p>\n\n<p>' +
1021+ options . email +
1022+ '<br>\nvia the ' +
1023+ options . sitename +
1024+ ' site</p>' ;
1025+ // HTML text
1026+ let htmlText = '' ;
1027+ const replacementsArray = [ ] ;
1028+ replacementsArray . push ( [ '<!--PROTOCOL-->' , options . protocol ] ) ;
1029+ replacementsArray . push ( [ '<!--HOST-->' , options . hostname ] ) ;
1030+ replacementsArray . push ( [ '<!--SITENAME-->' , options . sitename ] ) ;
1031+ replacementsArray . push ( [ '<!--TITLE-->' , subject ] ) ;
1032+ replacementsArray . push ( [ '<!--BODY-->' , message ] ) ;
1033+ replacementsArray . push ( [ '<!--EMAIL-->' , options . email ] ) ;
1034+ replacementsArray . push ( [ '<!--CODA-->' , '' ] ) ;
1035+ replacementsArray . push ( [
1036+ '<p>' ,
1037+ '<p style="margin-bottom: 10px; font-weight: normal; font: 13px/ 18px Arial, sans-serif; color: #000000;">'
1038+ ] ) ;
1039+ fs . readFile ( './templates/mail/default.html' , 'utf8' , ( err , f ) => {
1040+ if ( err )
1041+ debug ( err ) ;
1042+ htmlText = f ;
1043+ for ( let i = 0 ; i < replacementsArray . length ; i ++ ) {
1044+ const re = new RegExp ( replacementsArray [ i ] [ 0 ] , 'gi' ) ;
1045+ htmlText = htmlText . replace ( re , replacementsArray [ i ] [ 1 ] ) ;
1046+ }
1047+ // Plain text
1048+ const plainText = h2p ( message ) ;
1049+ const msg = {
1050+ to : _this . email ,
1051+ from : options . email ,
1052+ subject : subject ,
1053+ text : plainText ,
1054+ html : htmlText
1055+ } ;
1056+ sendMail ( msg , options . hostname ) ;
1057+ done ( null ) ;
1058+ } ) ;
10551059 } ) ;
10561060 }
10571061 sendResetNotification ( options , done ) {
0 commit comments