Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
m4lab_tv1
User Account
Commits
424fc8a4
Commit
424fc8a4
authored
May 26, 2020
by
Rosanny Sihombing
Browse files
MLAB-129: add welcome email after successful verification
parent
e7931881
Changes
2
Hide whitespace changes
Inline
Side-by-side
routes/methods.js
View file @
424fc8a4
...
...
@@ -80,6 +80,19 @@ var methods = {
}
callback
(
user
,
err
);
});
},
getUserById
:
function
(
userId
,
callback
)
{
dbconn
.
user
.
query
(
'
SELECT verificationStatus, email, salutation, title, firstname, lastname, industry, organisation, speciality FROM user WHERE id =
'
+
userId
,
function
(
err
,
rows
,
fields
)
{
if
(
err
)
{
throw
err
;
}
else
{
if
(
rows
.
length
>
0
)
{
user
=
rows
[
0
];
}
}
callback
(
user
,
err
);
});
},
checkUserEmail
:
function
(
email
,
callback
)
{
let
user
...
...
routes/routes-account.js
View file @
424fc8a4
...
...
@@ -581,9 +581,8 @@ module.exports = function (app, config, passport, i18n) {
// ============= USER VERIFICATION ================================
app
.
get
(
"
/verifyAccount
"
,
function
(
req
,
res
){
console
.
log
(
req
.
query
)
methods
.
getUserIdByVerificationToken
(
req
.
query
.
token
,
function
(
userId
,
err
){
console
.
log
(
err
)
console
.
log
(
userId
)
if
(
userId
)
{
let
userData
=
{
id
:
userId
,
...
...
@@ -597,6 +596,30 @@ module.exports = function (app, config, passport, i18n) {
});
}
else
{
// send welcome email after successful account verification
methods
.
getUserById
(
userId
,
function
(
data
,
err
){
if
(
err
)
{
console
.
log
(
"
Error:
"
+
err
)
}
else
{
// send email
var
emailSubject
=
"
Herzlich willkommen
"
var
emailContent
=
"
Lieber Nutzer,
\n\n
"
+
"
herzlich willkommen beim Transferportal der HFT Stuttgart!
\n
"
+
"
Sie können nun alle Dienste des Portals nutzen.
\n\n
"
+
mailSignature
mailer
.
options
.
to
=
data
.
email
;
mailer
.
options
.
subject
=
emailSubject
;
mailer
.
options
.
text
=
emailContent
;
mailer
.
transport
.
sendMail
(
mailer
.
options
,
function
(
err
)
{
if
(
err
)
{
console
.
log
(
'
cannot send email
'
)
throw
err
}
})
}
})
res
.
render
(
lang
+
'
/account/verification
'
,
{
status
:
true
});
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment