1 /* Copyright (c) 2019 AT&T Intellectual Property. #
\r
3 # Licensed under the Apache License, Version 2.0 (the "License"); #
\r
4 # you may not use this file except in compliance with the License. #
\r
5 # You may obtain a copy of the License at #
\r
7 # http://www.apache.org/licenses/LICENSE-2.0 #
\r
9 # Unless required by applicable law or agreed to in writing, software #
\r
10 # distributed under the License is distributed on an "AS IS" BASIS, #
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
\r
12 # See the License for the specific language governing permissions and #
\r
13 # limitations under the License. #
\r
14 ##############################################################################*/
\r
17 var env = require('config').env;
\r
19 module.exports = function(app) {
\r
21 function getLink(type, hash) {
\r
22 const url = app.get('otf').url + "account/" + type + '?token=' + hash;
\r
26 function sendEmail(email) {
\r
27 var environment = env.toUpperCase();
\r
28 email.subject = "Open Test Framework (" + environment + ") - " + email.subject;
\r
29 return app.service(app.get('base-path') + 'mailer').create(email).then(function (result) {
\r
30 console.log('Sent email', result)
\r
32 console.log('Error sending email: ', email, err)
\r
37 notifier: function(type, user, notifierOptions) {
\r
40 let sender = app.get('otf').email;
\r
42 case 'resendVerifySignup': //sending the user the verification email
\r
43 tokenLink = getLink('verify', user.verifyToken)
\r
47 subject: 'Verify Signup',
\r
48 html: 'Please verify your email address by clicking the link below.' + '</br>' + tokenLink
\r
51 return sendEmail(email)
\r
54 case 'verifySignup': // confirming verification
\r
55 let adminLink = app.get('otf').url + 'user-management?filter=' + user['email'];
\r
60 subject: 'Signup Confirmed',
\r
61 html: 'Thanks for verifying your email!' + '</br>' + 'You will be notified when an admin enables your account.'
\r
67 subject: 'Approve Verified User',
\r
68 html: 'User has verified their email.' + '</br>' +
\r
69 'Details: ' + '</br>' +
\r
70 ' Email: ' + user['email'] + '</br>' +
\r
71 ' First Name: ' + user['firstName'] + '</br>' +
\r
72 ' Last Name: ' + user['lastName'] + '</br>' +
\r
74 'Enable their account by visiting ' + '</br>' + adminLink
\r
76 sendEmail(adminEmail);
\r
77 return sendEmail(email);
\r
80 case 'sendApprovalNotification':
\r
84 subject: 'Approved',
\r
85 html: 'Your account has been approved for access.' + '</br>' +
\r
86 'You can now log into the OTF website: ' + app.get('otf').url
\r
89 return sendEmail(email);
\r
92 case 'sendResetPwd':
\r
93 tokenLink = getLink('reset', user.resetToken)
\r
95 return sendEmail(email)
\r
99 tokenLink = getLink('reset', user.resetToken)
\r
101 return sendEmail(email)
\r
104 case 'passwordChange':
\r
106 return sendEmail(email)
\r
109 case 'identityChange':
\r
110 tokenLink = getLink('verifyChanges', user.verifyToken)
\r
112 return sendEmail(email)
\r