@@ -95,21 +95,20 @@ function generateConfirmTokenLink(httpOrHttps, domain, type, token) {
9595/**
9696 * Generates the mailData for the account confirmation Email. This really only applies to
9797 * hackers as all other accounts are intrinsically confirmed via the email they recieve to invite them
98- * @param {string } hostname The hostname that this service is running on
98+ * @param {string } address The hostname that this service is running on
9999 * @param {string } receiverEmail The receiver of the email
100100 * @param {string } type the user type
101101 * @param {string } token The account confirmation token
102102 */
103- function generateAccountConfirmationEmail ( hostname , receiverEmail , type , token ) {
104- const httpOrHttps = ( hostname === "localhost" ) ? "http" : "https" ;
105- const address = ( hostname === "localhost" ) ? `localhost:${ process . env . PORT } ` : hostname ;
103+ function generateAccountConfirmationEmail ( address , receiverEmail , type , token ) {
104+ const httpOrHttps = ( address . includes ( "localhost" ) ) ? "http" : "https" ;
106105 const tokenLink = generateConfirmTokenLink ( httpOrHttps , address , type , token ) ;
107106 var emailSubject = "" ;
108107 if ( token === undefined || tokenLink === undefined ) {
109108 return undefined ;
110109 }
111110 if ( type === Constants . HACKER ) {
112- emailSubject = Constants . CONFIRM_ACC_EMAIL_SUBJECT
111+ emailSubject = Constants . CONFIRM_ACC_EMAIL_SUBJECT ;
113112 }
114113 const handlebarPath = path . join ( __dirname , `../assets/email/AccountConfirmation.hbs` ) ;
115114
@@ -125,30 +124,26 @@ function generateAccountConfirmationEmail(hostname, receiverEmail, type, token)
125124}
126125
127126/*
128- * Generates the mailData for the account invitation Email.
129- * @param {string } hostname The hostname that this service is running on
130- * @param {string } receiverEmail The receiver of the email
131- * @param {string } type The user type
132- * @param {string } token The account confirmation token
127+ * Generates the mailData for the account invitation Email.
128+ * @param {string } address The hostname that this service is running on
129+ * @param {string } receiverEmail The receiver of the email
130+ * @param {string } type The user type
131+ * @param {string } token The account confirmation token
133132 */
134- function generateAccountInvitationEmail ( hostname , receiverEmail , type , token ) {
135- const httpOrHttps = ( hostname === "localhost" ) ? "http" : "https" ;
136- const address = ( hostname === "localhost" ) ? `localhost:${ process . env . PORT } ` : hostname ;
133+ function generateAccountInvitationEmail ( address , receiverEmail , type , token ) {
134+ const httpOrHttps = ( address . includes ( "localhost" ) ) ? "http" : "https" ;
137135 const tokenLink = generateCreateAccountTokenLink ( httpOrHttps , address , type , token ) ;
138136 var emailSubject = "" ;
139137 if ( token === undefined || tokenLink === undefined ) {
140138 return undefined ;
141139 }
142140 if ( type === Constants . HACKER ) {
143141 emailSubject = Constants . CREATE_ACC_EMAIL_SUBJECTS [ Constants . HACKER ] ;
144- }
145- else if ( type === Constants . VOLUNTEER ) {
142+ } else if ( type === Constants . VOLUNTEER ) {
146143 emailSubject = Constants . CREATE_ACC_EMAIL_SUBJECTS [ Constants . VOLUNTEER ] ;
147- }
148- else if ( Constants . SPONSOR_TIERS . includes ( type ) ) {
144+ } else if ( Constants . SPONSOR_TIERS . includes ( type ) ) {
149145 emailSubject = Constants . CREATE_ACC_EMAIL_SUBJECTS [ Constants . SPONSOR ] ;
150- }
151- else if ( type === Constants . STAFF ) {
146+ } else if ( type === Constants . STAFF ) {
152147 emailSubject = Constants . CREATE_ACC_EMAIL_SUBJECTS [ Constants . STAFF ] ;
153148 }
154149 const handlebarPath = path . join ( __dirname , `../assets/email/AccountInvitation.hbs` ) ;
0 commit comments