Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
m4lab_tv1
User Account
Commits
3000c768
Commit
3000c768
authored
3 years ago
by
Rosanny Sihombing
Browse files
Options
Download
Email Patches
Plain Diff
add a new route
parent
ea1e33a1
master
MLAB-677
devel
reset-jul13
reset-merge
testing
5 merge requests
!143
updating yml config
,
!91
Prepare prod
,
!90
Testing
,
!89
Testing
,
!81
Mlab 87
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app.js
+2
-0
app.js
routes/public.js
+136
-0
routes/public.js
with
138 additions
and
0 deletions
+138
-0
app.js
+
2
-
0
View file @
3000c768
...
...
@@ -18,6 +18,7 @@ i18n.configure({
locales
:[
'
de
'
,
'
en
'
],
directory
:
'
./locales
'
});
const
lang
=
'
DE
'
var
env
=
process
.
env
.
NODE_ENV
||
'
testing
'
;
const
config
=
require
(
'
./config/config
'
)[
env
];
...
...
@@ -69,6 +70,7 @@ app.use(function(req, res, next) {
});
require
(
'
./routes/routes-account
'
)(
app
,
config
,
passport
,
i18n
);
require
(
'
./routes/public
'
)(
app
,
config
,
lang
);
// Handle 404
app
.
use
(
function
(
req
,
res
)
{
...
...
This diff is collapsed.
Click to expand it.
routes/public.js
0 → 100644
+
136
-
0
View file @
3000c768
const
methods
=
require
(
'
../functions/methods
'
)
const
async
=
require
(
'
async
'
)
const
mailer
=
require
(
'
../config/mailer
'
)
const
constants
=
require
(
'
../config/const
'
)
// pwd encryption
const
crypto
=
require
(
'
crypto
'
)
const
bcrypt
=
require
(
'
bcryptjs
'
)
const
saltRounds
=
10
const
salt
=
64
module
.
exports
=
function
(
app
,
config
,
lang
)
{
// ============= NEW USERS REGISTRATION ===========================
app
.
get
(
'
/registration
'
,
function
(
req
,
res
)
{
res
.
render
(
lang
+
'
/account/registration
'
)
})
app
.
post
(
'
/registration
'
,
function
(
req
,
res
)
{
// user data
var
curDate
=
new
Date
()
var
userData
=
{
salutation
:
req
.
body
.
inputSalutation
,
title
:
req
.
body
.
inputTitle
,
firstname
:
req
.
body
.
inputFirstname
,
lastname
:
req
.
body
.
inputLastname
,
email
:
req
.
body
.
inputEmail
,
organisation
:
req
.
body
.
inputOrganisation
,
industry
:
req
.
body
.
inputIndustry
,
speciality
:
req
.
body
.
inputSpeciality
,
createdDate
:
curDate
.
toISOString
().
slice
(
0
,
10
)
}
var
userEmail
=
userData
.
email
var
pos
=
userEmail
.
indexOf
(
'
@
'
)
var
emailLength
=
userEmail
.
length
var
emailDomain
=
userEmail
.
slice
(
pos
,
emailLength
);
if
(
emailDomain
.
toLowerCase
()
==
"
@hft-stuttgart.de
"
)
{
res
.
flash
(
'
error
'
,
"
Fehlgeschlagen: HFT-Account
"
)
res
.
redirect
(
'
/account/registration
'
)
}
else
{
let
token
async
.
waterfall
([
function
(
done
)
{
crypto
.
randomBytes
(
20
,
function
(
err
,
buf
)
{
token
=
buf
.
toString
(
'
hex
'
);
done
(
err
,
token
);
});
},
// encrypt password
function
(
token
,
done
)
{
bcrypt
.
genSalt
(
saltRounds
,
function
(
err
,
salt
)
{
bcrypt
.
hash
(
req
.
body
.
inputPassword
,
salt
,
function
(
err
,
hash
)
{
var
newAccount
=
{
profile
:
userData
,
password
:
hash
,
verificationToken
:
token
}
done
(
err
,
newAccount
)
});
});
},
// save data
function
(
newAccount
,
err
)
{
methods
.
registerNewUser
(
newAccount
,
function
(
err
){
if
(
err
)
{
res
.
flash
(
'
error
'
,
"
Fehlgeschlagen
"
)
}
else
{
// send email
var
emailSubject
=
"
Bitte bestätigen Sie Ihr M4_LAB Benutzerkonto
"
var
emailContent
=
'
<div>Lieber Nutzer,<br/><br/>
'
+
'
<p>vielen Dank für Ihre Anmeldung am Transferportal der HFT Stuttgart. <br/>
'
+
'
Um Ihre Anmeldung zu bestätigen, klicken Sie bitte <a href=
'
+
config
.
app
.
host
+
'
/verifyAccount?token=
'
+
token
+
'
>diesen Link</a>
'
+
'
<br/><br/>
'
+
'
Ohne Bestätigung Ihres Kontos müssen wir Ihr Konto leider nach 7 Tagen löschen.</p><br/>
'
+
constants
.
mailSignature
+
'
</div>
'
;
mailer
.
options
.
to
=
req
.
body
.
inputEmail
;
mailer
.
options
.
subject
=
emailSubject
;
mailer
.
options
.
html
=
emailContent
;
mailer
.
transport
.
sendMail
(
mailer
.
options
,
function
(
err
)
{
if
(
err
)
{
console
.
log
(
'
cannot send email
'
)
throw
err
}
})
// user feedback
res
.
flash
(
'
success
'
,
'
Vielen Dank für Ihre Registrierung!
'
+
'
\r\n\r\n
'
+
'
Wir haben Ihnen eine E-Mail an Ihre verwendete Adresse gesendet. Diese enthält einen Link zur Bestätigung Ihres Accounts.
'
+
'
\r\n
'
+
'
Wenn Sie die Mail nicht in ihrem Postfach vorfinden, prüfen Sie bitte auch Ihren Spam-Ordner.
'
)
}
res
.
redirect
(
'
/account/registration
'
)
})
}
])
}
})
// ============= CONTACT FORM ===========================
app
.
get
(
'
/contact
'
,
function
(
req
,
res
)
{
res
.
render
(
lang
+
'
/account/contact
'
,
{
user
:
req
.
user
})
})
app
.
post
(
'
/contact
'
,
function
(
req
,
res
,
next
)
{
//methods.currentDate();
let
emailAddress
=
req
.
body
.
inputEmail
;
let
supportAddress
=
"
support-transfer@hft-stuttgart.de
"
;
let
inputName
=
req
.
body
.
name
;
let
inputContent
=
req
.
body
.
message
;
let
emailContent
=
"
Es wurde eine Anfrage an das Transferportal gestellt:
\n\n
NAME:
"
+
inputName
+
"
\n
NACHRICHT:
\n
"
+
inputContent
;
let
emailSubject
=
"
Ihre Anfrage an das Transferportal
"
;
async
.
waterfall
([
function
(
done
)
{
// send email
mailer
.
options
.
to
=
supportAddress
;
mailer
.
options
.
cc
=
emailAddress
;
mailer
.
options
.
subject
=
emailSubject
;
mailer
.
options
.
text
=
emailContent
;
mailer
.
transport
.
sendMail
(
mailer
.
options
,
function
(
err
)
{
done
(
err
,
'
done
'
);
});
}
],
function
(
err
)
{
if
(
err
)
{
res
.
flash
(
'
error
'
,
'
Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut.
'
);
}
else
{
res
.
flash
(
'
success
'
,
'
Vielen Dank für Ihre Anfrage. Wir melden uns baldmöglichst bei Ihnen. Eine Kopie Ihrer Anfrage wurde an
'
+
emailAddress
+
'
versandt.
'
);
}
res
.
redirect
(
'
/account/contact
'
)
})
})
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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
Menu
Explore
Projects
Groups
Snippets