Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
m4lab_tv1
User Account
Commits
ed62b6df
Commit
ed62b6df
authored
May 05, 2021
by
Rosanny Sihombing
Browse files
restructure the project
parent
3000c768
Changes
8
Hide whitespace changes
Inline
Side-by-side
config/const.js
0 → 100644
View file @
ed62b6df
module
.
exports
=
{
mailSignature
:
'
Mit den besten Grüßen,<br/>das Transferportal-Team der HFT Stuttgart<br/><br/>
'
+
'
Transferportal der Hochschule für Technik Stuttgart<br/>
'
+
'
Schellingstr. 24 70174 Stuttgart<br/>
'
+
'
m4lab@hft-stuttgart.de<br/>
'
+
'
<a href="https://transfer.hft-stuttgart.de">https://transfer.hft-stuttgart.de</a><br/>
'
+
'
<a href="http://www.hft-stuttgart.de/Aktuell/"><img border="0" alt="HFT" src="https://m4lab.hft-stuttgart.de/img/signature/hft_logo.png" width="30" height="30"></a>
'
+
'
<a href="http://www.facebook.com/hftstuttgart"><img border="0" alt="Facebook" src="https://m4lab.hft-stuttgart.de/img/signature/fb_bw.png" width="30" height="30"></a>
'
+
'
<a href="https://www.instagram.com/hft_stuttgart/"><img border="0" alt="Instagram" src="https://m4lab.hft-stuttgart.de/img/signature/instagram_bw.png" width="30" height="30"></a>
'
+
'
<a href="https://twitter.com/hft_presse"><img border="0" alt="Twitter" src="https://m4lab.hft-stuttgart.de/img/signature/twitter_bw.png" width="30" height="30"></a>
'
+
'
<a href="https://www.youtube.com/channel/UCi0_JfF2qMZbOhOnNH5PyHA"><img border="0" alt="Youtube" src="https://m4lab.hft-stuttgart.de/img/signature/youtube_bw.png" width="30" height="30"></a>
'
+
'
<a href="http://www.hft-stuttgart.de/Aktuell/Presse-Marketing/SocialMedia/Snapcode HFT_Stuttgart.jpg/photo_view">
'
+
'
<img border="0" alt="Snapchat" src="https://m4lab.hft-stuttgart.de/img/signature/snapchat_bw.png" width="30" height="30"></a>
'
+
'
<br/><img border="0" src="https://m4lab.hft-stuttgart.de/img/signature/inno_bw.png" width="150" height="100">
'
}
\ No newline at end of file
routes
/dbconn.js
→
config
/dbconn.js
View file @
ed62b6df
const
mysql
=
require
(
'
mysql
'
)
var
env
=
process
.
env
.
NODE_ENV
||
'
testing
'
;
const
config
=
require
(
'
.
./config
/config
'
)[
env
]
var
env
=
process
.
env
.
NODE_ENV
||
'
development
'
;
const
config
=
require
(
'
./config
'
)[
env
]
// ==== USER ACOOUNT DB CONNECTION ====
var
userConnection
=
mysql
.
createConnection
({
...
...
routes
/dbconn2.js
→
config
/dbconn2.js
View file @
ed62b6df
const
mysql
=
require
(
'
mysql2
'
)
var
env
=
process
.
env
.
NODE_ENV
||
'
testing
'
;
const
config
=
require
(
'
.
./config
/config
'
)[
env
]
var
env
=
process
.
env
.
NODE_ENV
||
'
development
'
;
const
config
=
require
(
'
./config
'
)[
env
]
// ==== USER ACOOUNT DB CONNECTION ====
var
userConnection
=
mysql
.
createConnection
({
...
...
routes
/mailer.js
→
config
/mailer.js
View file @
ed62b6df
const
nodemailer
=
require
(
'
nodemailer
'
)
var
env
=
process
.
env
.
NODE_ENV
||
'
testing
'
;
const
config
=
require
(
'
.
./config
/config
'
)[
env
]
const
config
=
require
(
'
./config
'
)[
env
]
var
smtpTransport
=
nodemailer
.
createTransport
({
host
:
config
.
mailer
.
host
,
...
...
route
s/gitlab.js
→
function
s/gitlab.js
View file @
ed62b6df
File moved
route
s/helpers.js
→
function
s/helpers.js
View file @
ed62b6df
File moved
route
s/methods.js
→
function
s/methods.js
View file @
ed62b6df
const
dbconn_OBSOLETE
=
require
(
'
./dbconn
'
)
// DO NOT USE THIS FOR NEW F
EATURE
const
dbconn
=
require
(
'
./dbconn2
'
)
const
dbconn_OBSOLETE
=
require
(
'
.
./config
/dbconn
'
)
// DO NOT USE THIS FOR NEW F
UNCTIONS
const
dbconn
=
require
(
'
.
./config
/dbconn2
'
)
var
methods
=
{
// ===================== user db =====================
...
...
@@ -65,18 +65,6 @@ var methods = {
callback
(
err
)
})
},
getUserByEmail_OBSOLETE
:
function
(
email
,
callback
)
{
dbconn_OBSOLETE
.
user
.
query
(
'
SELECT id, verificationStatus, salutation, title, firstname, lastname, industry, organisation, speciality, m4lab_idp FROM user WHERE email = "
'
+
email
+
'
"
'
,
function
(
err
,
rows
,
fields
)
{
let
user
if
(
err
)
{
throw
err
}
else
{
if
(
rows
.
length
>
0
)
{
user
=
rows
[
0
]
}
}
callback
(
user
,
err
)
});
},
getUserByEmail
:
async
function
(
email
)
{
try
{
let
rows
=
await
dbconn
.
user
.
promise
().
query
(
'
SELECT id, verificationStatus, salutation, title, firstname, lastname, industry, organisation, speciality, m4lab_idp FROM user WHERE email = "
'
+
email
+
'
"
'
)
...
...
routes/routes-account.js
View file @
ed62b6df
const
fs
=
require
(
'
fs
'
)
const
SamlStrategy
=
require
(
'
passport-saml
'
).
Strategy
const
dbconn
=
require
(
'
./dbconn
'
)
const
methods
=
require
(
'
./methods
'
)
const
gitlab
=
require
(
'
./gitlab
'
)
const
dbconn
=
require
(
'
.
./config
/dbconn
'
)
const
methods
=
require
(
'
.
./functions
/methods
'
)
const
gitlab
=
require
(
'
.
./functions
/gitlab
'
)
// pwd encryption
const
bcrypt
=
require
(
'
bcryptjs
'
);
const
saltRounds
=
10
;
...
...
@@ -10,7 +10,7 @@ const salt = 64; // salt length
// forgot pwd
const
async
=
require
(
'
async
'
)
const
crypto
=
require
(
'
crypto
'
)
const
mailer
=
require
(
'
./mailer
'
)
const
mailer
=
require
(
'
.
./config
/mailer
'
)
const
logoDir
=
'
public/upload/
'
const
defaultLogo
=
'
public/default/logo.png
'
const
tpGitlabURL
=
'
https://transfer.hft-stuttgart.de/gitlab/
'
...
...
@@ -668,97 +668,6 @@ module.exports = function (app, config, passport, i18n) {
}
})
// ============= 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 = "Lieber Nutzer,\n\n"+
// "vielen Dank für Ihre Anmeldung am Transferportal der HFT Stuttgart.\n"+
// "Um Ihre Anmeldung zu bestätigen, klicken Sie bitte diesen Link: "+config.app.host+"/verifyAccount?token="+token+"\n"+
// "Ohne Bestätigung Ihres Kontos müssen wir Ihr Konto leider nach 7 Tagen löschen.\n\n"+
// "Sollten Sie sich selbst nicht mit Ihren Daten am Transferportal registriert haben, ignorieren Sie diese E-Mail bitte.\n\n"+mailSignature
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 diesen Link:
'
+
config
.
app
.
host
+
'
/verifyAccount?token=
'
+
token
+
'
<br/><br/>
'
+
'
Ohne Bestätigung Ihres Kontos müssen wir Ihr Konto leider nach 7 Tagen löschen.</p><br/>
'
+
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
'
)
})
}
])
}
})
// ============= USER VERIFICATION ================================
app
.
get
(
"
/verifyAccount
"
,
function
(
req
,
res
){
methods
.
getUserIdByVerificationToken
(
req
.
query
.
token
,
function
(
userId
,
err
){
...
...
@@ -870,40 +779,4 @@ module.exports = function (app, config, passport, i18n) {
})
})
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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