Commit f5be0bd6 authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

devel configuration

parent 98e0620d
module.exports = { module.exports = {
development: { development: {
app: { app: {
hostname: 'm4lab.hft-stuttgart.de/account',
name: 'User Account Management', name: 'User Account Management',
hostname: 'm4lab.hft-stuttgart.de/account',
port: process.env.PORT || 9989 port: process.env.PORT || 9989
}, },
passport: { passport: {
...@@ -11,12 +9,12 @@ module.exports = { ...@@ -11,12 +9,12 @@ module.exports = {
saml: { saml: {
path: process.env.SAML_PATH || '/saml/SSO', path: process.env.SAML_PATH || '/saml/SSO',
entryPoint: process.env.SAML_ENTRY_POINT || 'https://transfer.hft-stuttgart.de/idp/saml2/idp/SSOService.php', entryPoint: process.env.SAML_ENTRY_POINT || 'https://transfer.hft-stuttgart.de/idp/saml2/idp/SSOService.php',
issuer: 'sp-account-testing.m4lab.hft-stuttgart.de', issuer: 'sp-account.m4lab.hft-stuttgart.de',
logoutUrl: 'https://transfer.hft-stuttgart.de/idp/saml2/idp/SingleLogoutService.php' logoutUrl: 'https://transfer.hft-stuttgart.de/idp/saml2/idp/SingleLogoutService.php'
} }
}, },
database: { database: {
host: 'transfer.hft-stuttgart.de', // DB host host: 'localhost', // DB host
user: 'DBManager', // DB username user: 'DBManager', // DB username
password: 'Stuttgart2019', // DB password password: 'Stuttgart2019', // DB password
port: 3306, // MySQL port port: 3306, // MySQL port
......
...@@ -18,7 +18,7 @@ userConnection.connect(function(err) { ...@@ -18,7 +18,7 @@ userConnection.connect(function(err) {
}) })
userConnection.query('USE '+config.database.dbUser) userConnection.query('USE '+config.database.dbUser)
// db connection test // user db connection test
userConnection.query('SELECT 1 + 5 AS solution', function (err, rows, fields) { userConnection.query('SELECT 1 + 5 AS solution', function (err, rows, fields) {
if (err) throw err if (err) throw err
console.log('Solution = ', rows[0].solution) console.log('Solution = ', rows[0].solution)
......
...@@ -64,27 +64,16 @@ module.exports = function (app, config, passport) { ...@@ -64,27 +64,16 @@ module.exports = function (app, config, passport) {
res.send(JSON.stringify(req.flash('test'))); res.send(JSON.stringify(req.flash('test')));
}); });
*/ */
app.get('/', function (req, res) {
res.redirect('/account/profile')
});
app.get('/login',
passport.authenticate(config.passport.strategy,
{
successRedirect: '/account/',
failureRedirect: '/account/login'
})
);
// ============= SAML ============== // ============= SAML ==============
app.post(config.passport.saml.path, app.post(config.passport.saml.path,
passport.authenticate(config.passport.strategy, passport.authenticate(config.passport.strategy,
{ {
failureRedirect: '/account/', failureRedirect: '/',
failureFlash: true failureFlash: true
}), }),
function (req, res) { function (req, res) {
res.redirect('/account/'); res.redirect('/');
} }
); );
...@@ -120,14 +109,18 @@ module.exports = function (app, config, passport) { ...@@ -120,14 +109,18 @@ module.exports = function (app, config, passport) {
// ======== APP ROUTES ==================== // ======== APP ROUTES ====================
app.get('/', function (req, res) { app.get('/', function (req, res) {
res.redirect('/account/profile') res.redirect('/profile')
});
app.get('/error', function (req, res) {
res.render('error')
}); });
app.get('/login', app.get('/login',
passport.authenticate(config.passport.strategy, passport.authenticate(config.passport.strategy,
{ {
successRedirect: '/account/', successRedirect: '/',
failureRedirect: '/account/login' failureRedirect: '/login'
}) })
); );
...@@ -153,7 +146,6 @@ module.exports = function (app, config, passport) { ...@@ -153,7 +146,6 @@ module.exports = function (app, config, passport) {
}); });
}); });
app.get('/profile', function (req, res) { app.get('/profile', function (req, res) {
if (req.isAuthenticated()) { if (req.isAuthenticated()) {
methods.getUserByEmail(req.user.email, function(data, err){ methods.getUserByEmail(req.user.email, function(data, err){
...@@ -165,7 +157,7 @@ module.exports = function (app, config, passport) { ...@@ -165,7 +157,7 @@ module.exports = function (app, config, passport) {
} }
}) })
} else { } else {
res.redirect('/account/login'); res.redirect('/login');
} }
}); });
...@@ -229,18 +221,17 @@ module.exports = function (app, config, passport) { ...@@ -229,18 +221,17 @@ module.exports = function (app, config, passport) {
} }
]) ])
} else { } else {
res.redirect('/account/login'); res.redirect('/login');
} }
}); });
app.get('/security', function (req, res) { app.get('/security', function (req, res) {
if (req.isAuthenticated()) { if (req.isAuthenticated()) {
console.log(req.user)
res.render('security', { res.render('security', {
user: req.user // useful for view engine, useless for HTML user: req.user // useful for view engine, useless for HTML
}); });
} else { } else {
res.redirect('/account/login'); res.redirect('/login');
} }
}); });
...@@ -265,11 +256,11 @@ module.exports = function (app, config, passport) { ...@@ -265,11 +256,11 @@ module.exports = function (app, config, passport) {
else { else {
req.flash('success', 'Profile updated!'); req.flash('success', 'Profile updated!');
} }
res.redirect('/account/profile'); res.redirect('/profile');
}) })
} }
} else { } else {
res.redirect('/account/login'); res.redirect('/login');
} }
}); });
...@@ -284,7 +275,7 @@ module.exports = function (app, config, passport) { ...@@ -284,7 +275,7 @@ module.exports = function (app, config, passport) {
// Load hashed passwd from DB // Load hashed passwd from DB
dbconn.user.query('SELECT password FROM credential WHERE user_id='+userId, function (err, rows, fields) { dbconn.user.query('SELECT password FROM credential WHERE user_id='+userId, function (err, rows, fields) {
if (err) { if (err) {
res.redirect('/account/500') res.redirect('/500')
throw err throw err
} }
var userPwd = rows[0].password var userPwd = rows[0].password
...@@ -297,12 +288,12 @@ module.exports = function (app, config, passport) { ...@@ -297,12 +288,12 @@ module.exports = function (app, config, passport) {
} }
else if (!isMatch) { else if (!isMatch) {
req.flash('error', "Sorry, your password was incorrect. Please double-check your password.") req.flash('error', "Sorry, your password was incorrect. Please double-check your password.")
res.redirect('/account/security') res.redirect('/security')
} }
else { else {
if ( newPwd != retypePwd ) { if ( newPwd != retypePwd ) {
req.flash('error', "Passwords do no match. Please make sure you re-type your new password correctly.") req.flash('error', "Passwords do no match. Please make sure you re-type your new password correctly.")
res.redirect('/account/security') res.redirect('/security')
} }
else { else {
// update password // update password
...@@ -321,7 +312,7 @@ module.exports = function (app, config, passport) { ...@@ -321,7 +312,7 @@ module.exports = function (app, config, passport) {
req.flash('success', "Pasword updated!") req.flash('success', "Pasword updated!")
console.log('pasword updated!') console.log('pasword updated!')
} }
res.redirect('/account/security') res.redirect('/security')
}) })
}); });
}); });
...@@ -333,7 +324,7 @@ module.exports = function (app, config, passport) { ...@@ -333,7 +324,7 @@ module.exports = function (app, config, passport) {
}) })
} }
else { else {
res.redirect('/account/login'); res.redirect('/login');
} }
}); });
...@@ -399,16 +390,15 @@ module.exports = function (app, config, passport) { ...@@ -399,16 +390,15 @@ module.exports = function (app, config, passport) {
else { else {
req.flash('success', 'An e-mail has been sent to ' + emailAddress + ' with further instructions.'); req.flash('success', 'An e-mail has been sent to ' + emailAddress + ' with further instructions.');
} }
res.redirect('/account/forgotPwd'); res.redirect('/forgotPwd');
}); });
}); });
app.get('/reset/:token', function(req, res) { app.get('/reset/:token', function(req, res) {
methods.checkUserToken(req.params.token, function(err, user){ methods.checkUserToken(req.params.token, function(err, user){
//console.log(user);
if (!user) { if (!user) {
req.flash('error', 'Password reset token is invalid or has expired.'); req.flash('error', 'Password reset token is invalid or has expired.');
res.redirect('/account/forgotPwd'); res.redirect('/forgotPwd');
} }
else { else {
res.render('reset'); res.render('reset');
...@@ -494,9 +484,6 @@ module.exports = function (app, config, passport) { ...@@ -494,9 +484,6 @@ module.exports = function (app, config, passport) {
}); });
}) })
app.get('/email/:email', function(req, res) { app.get('/email/:email', function(req, res) {
methods.checkUserEmail(req.params.email, function(err, user){ methods.checkUserEmail(req.params.email, function(err, user){
......
...@@ -35,8 +35,8 @@ html(lang="en") ...@@ -35,8 +35,8 @@ html(lang="en")
span #{user.firstname} #{user.lastname} span #{user.firstname} #{user.lastname}
div(class="nav flex-column nav-pills", id="v-pills-tab", role="tablist", aria-orientation="vertical") div(class="nav flex-column nav-pills", id="v-pills-tab", role="tablist", aria-orientation="vertical")
a(class="nav-link" href="#" aria-selected="true") Profile a(class="nav-link" href="#" aria-selected="true") Profile
a(class="nav-link" href="/account/security" aria-selected="false") Security a(class="nav-link" href="/security" aria-selected="false") Security
a(class="nav-link" href="/account/services" aria-selected="false") Services a(class="nav-link" href="/services" aria-selected="false") Services
div(class="col-sm-9") div(class="col-sm-9")
if successes if successes
for success in successes for success in successes
...@@ -50,13 +50,18 @@ html(lang="en") ...@@ -50,13 +50,18 @@ html(lang="en")
div(class="form-row") div(class="form-row")
div(class='form-group col-md-2') div(class='form-group col-md-2')
label(for="title") Title label(for="title") Title
// to read: https://stackoverflow.com/questions/39997579/pug-templates-how-to-mark-option-in-dropdown-list-as-selected
select#inputTitle(name="inputTitle", class="form-control", value=user.title) select#inputTitle(name="inputTitle", class="form-control", value=user.title)
option(value="Frau/Herr") Frau/Herr option(value="Frau/Herr") Frau/Herr
option(value="Frau") Frau option(value="Frau") Frau
option(value="Herr") Herr option(value="Herr") Herr
option(value="Dr.") Dr. option(value="Dr.") Dr.
option(value="Prof. Dr.") Prof. Dr. option(value="Prof. Dr.") Prof. Dr.
script.
var titleOptions = document.getElementById('inputTitle').options;
for (i=0; i < titleOptions.length; i++) {
if (titleOptions[i].value == '#{user.title}')
titleOptions[i].selected = true;
}
div(class='form-group col-md-3') div(class='form-group col-md-3')
label(for="firstname") Vorname label(for="firstname") Vorname
input#inputFirstname(name="inputFirstname", type="text", class="form-control", placeholder="Vorname", value=user.firstname required) input#inputFirstname(name="inputFirstname", type="text", class="form-control", placeholder="Vorname", value=user.firstname required)
...@@ -87,4 +92,5 @@ html(lang="en") ...@@ -87,4 +92,5 @@ html(lang="en")
// Bootstrap // Bootstrap
script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous") script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous")
// M4_LAB // M4_LAB
script(src="/js/headfoot.js") script(src="https://transfer.hft-stuttgart.de/js/headfoot.js")
...@@ -37,9 +37,9 @@ html(lang="en") ...@@ -37,9 +37,9 @@ html(lang="en")
h5 h5
span #{user.firstName} #{user.lastName} span #{user.firstName} #{user.lastName}
div(class="nav flex-column nav-pills", id="v-pills-tab", role="tablist", aria-orientation="vertical") div(class="nav flex-column nav-pills", id="v-pills-tab", role="tablist", aria-orientation="vertical")
a(class="nav-link" href="/account/profile" aria-selected="true") Profile a(class="nav-link" href="/profile" aria-selected="true") Profile
a(class="nav-link" href="#" aria-selected="false") Security a(class="nav-link" href="#" aria-selected="false") Security
a(class="nav-link" href="/account/services" aria-selected="false") Services a(class="nav-link" href="/services" aria-selected="false") Services
div(class="col-sm-9") div(class="col-sm-9")
if successes if successes
for success in successes for success in successes
...@@ -49,7 +49,7 @@ html(lang="en") ...@@ -49,7 +49,7 @@ html(lang="en")
for error, i in errors for error, i in errors
div.alert.alert-danger.alert-dismissible.fade.show #{ error } div.alert.alert-danger.alert-dismissible.fade.show #{ error }
a(class="close", href="#", data-dismiss="alert", aria-label="close") &times; a(class="close", href="#", data-dismiss="alert", aria-label="close") &times;
form(class="needs-validation", method="post", action="/account/changePwd" novalidate) form(class="needs-validation", method="post", action="/changePwd" novalidate)
div(class="form-group row") div(class="form-group row")
label(for="currPwd") Current Password label(for="currPwd") Current Password
input(id="inputCurrPwd", name="inputCurrPwd", type="password", class="form-control" required) input(id="inputCurrPwd", name="inputCurrPwd", type="password", class="form-control" required)
...@@ -72,9 +72,9 @@ html(lang="en") ...@@ -72,9 +72,9 @@ html(lang="en")
// Bootstrap // Bootstrap
script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous") script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous")
// M4_LAB // M4_LAB
script(src="/account/js/security.js") script(src="/js/security.js")
script(src="/account/js/generalFunction.js") script(src="/js/generalFunction.js")
script(src="/js/headfoot.js") script(src="https://transfer.hft-stuttgart.de/js/headfoot.js")
script. script.
// check input fields // check input fields
'use strict'; 'use strict';
......
...@@ -34,8 +34,8 @@ html(lang="en") ...@@ -34,8 +34,8 @@ html(lang="en")
h5 h5
span #{user.firstName} #{user.lastName} span #{user.firstName} #{user.lastName}
div(class="nav flex-column nav-pills", id="v-pills-tab", role="tablist", aria-orientation="vertical") div(class="nav flex-column nav-pills", id="v-pills-tab", role="tablist", aria-orientation="vertical")
a(class="nav-link" href="/account/profile" aria-selected="true") Profile a(class="nav-link" href="/profile" aria-selected="true") Profile
a(class="nav-link" href="/account/security" aria-selected="false") Security a(class="nav-link" href="/security" aria-selected="false") Security
a(class="nav-link" href="#" aria-selected="false") Services a(class="nav-link" href="#" aria-selected="false") Services
div(class="col-sm-9") div(class="col-sm-9")
if successes if successes
...@@ -60,4 +60,4 @@ html(lang="en") ...@@ -60,4 +60,4 @@ html(lang="en")
// Bootstrap // Bootstrap
script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous") script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous")
// M4_LAB // M4_LAB
script(src="/js/headfoot.js") script(src="https://transfer.hft-stuttgart.de/js/headfoot.js")
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment