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

devel configuration

parent 98e0620d
module.exports = {
development: {
app: {
hostname: 'm4lab.hft-stuttgart.de/account',
name: 'User Account Management',
hostname: 'm4lab.hft-stuttgart.de/account',
port: process.env.PORT || 9989
},
passport: {
......@@ -11,12 +9,12 @@ module.exports = {
saml: {
path: process.env.SAML_PATH || '/saml/SSO',
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'
}
},
database: {
host: 'transfer.hft-stuttgart.de', // DB host
host: 'localhost', // DB host
user: 'DBManager', // DB username
password: 'Stuttgart2019', // DB password
port: 3306, // MySQL port
......
......@@ -18,7 +18,7 @@ userConnection.connect(function(err) {
})
userConnection.query('USE '+config.database.dbUser)
// db connection test
// user db connection test
userConnection.query('SELECT 1 + 5 AS solution', function (err, rows, fields) {
if (err) throw err
console.log('Solution = ', rows[0].solution)
......
......@@ -64,27 +64,16 @@ module.exports = function (app, config, passport) {
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 ==============
app.post(config.passport.saml.path,
passport.authenticate(config.passport.strategy,
{
failureRedirect: '/account/',
failureRedirect: '/',
failureFlash: true
}),
function (req, res) {
res.redirect('/account/');
res.redirect('/');
}
);
......@@ -120,14 +109,18 @@ module.exports = function (app, config, passport) {
// ======== APP ROUTES ====================
app.get('/', function (req, res) {
res.redirect('/account/profile')
res.redirect('/profile')
});
app.get('/error', function (req, res) {
res.render('error')
});
app.get('/login',
passport.authenticate(config.passport.strategy,
{
successRedirect: '/account/',
failureRedirect: '/account/login'
successRedirect: '/',
failureRedirect: '/login'
})
);
......@@ -153,7 +146,6 @@ module.exports = function (app, config, passport) {
});
});
app.get('/profile', function (req, res) {
if (req.isAuthenticated()) {
methods.getUserByEmail(req.user.email, function(data, err){
......@@ -165,7 +157,7 @@ module.exports = function (app, config, passport) {
}
})
} else {
res.redirect('/account/login');
res.redirect('/login');
}
});
......@@ -229,18 +221,17 @@ module.exports = function (app, config, passport) {
}
])
} else {
res.redirect('/account/login');
res.redirect('/login');
}
});
app.get('/security', function (req, res) {
if (req.isAuthenticated()) {
console.log(req.user)
res.render('security', {
user: req.user // useful for view engine, useless for HTML
});
} else {
res.redirect('/account/login');
res.redirect('/login');
}
});
......@@ -265,11 +256,11 @@ module.exports = function (app, config, passport) {
else {
req.flash('success', 'Profile updated!');
}
res.redirect('/account/profile');
res.redirect('/profile');
})
}
} else {
res.redirect('/account/login');
res.redirect('/login');
}
});
......@@ -284,7 +275,7 @@ module.exports = function (app, config, passport) {
// Load hashed passwd from DB
dbconn.user.query('SELECT password FROM credential WHERE user_id='+userId, function (err, rows, fields) {
if (err) {
res.redirect('/account/500')
res.redirect('/500')
throw err
}
var userPwd = rows[0].password
......@@ -297,12 +288,12 @@ module.exports = function (app, config, passport) {
}
else if (!isMatch) {
req.flash('error', "Sorry, your password was incorrect. Please double-check your password.")
res.redirect('/account/security')
res.redirect('/security')
}
else {
if ( newPwd != retypePwd ) {
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 {
// update password
......@@ -321,7 +312,7 @@ module.exports = function (app, config, passport) {
req.flash('success', "Pasword updated!")
console.log('pasword updated!')
}
res.redirect('/account/security')
res.redirect('/security')
})
});
});
......@@ -333,7 +324,7 @@ module.exports = function (app, config, passport) {
})
}
else {
res.redirect('/account/login');
res.redirect('/login');
}
});
......@@ -399,16 +390,15 @@ module.exports = function (app, config, passport) {
else {
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) {
methods.checkUserToken(req.params.token, function(err, user){
//console.log(user);
if (!user) {
req.flash('error', 'Password reset token is invalid or has expired.');
res.redirect('/account/forgotPwd');
res.redirect('/forgotPwd');
}
else {
res.render('reset');
......@@ -494,9 +484,6 @@ module.exports = function (app, config, passport) {
});
})
app.get('/email/:email', function(req, res) {
methods.checkUserEmail(req.params.email, function(err, user){
......
......@@ -35,8 +35,8 @@ html(lang="en")
span #{user.firstname} #{user.lastname}
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="/account/security" aria-selected="false") Security
a(class="nav-link" href="/account/services" aria-selected="false") Services
a(class="nav-link" href="/security" aria-selected="false") Security
a(class="nav-link" href="/services" aria-selected="false") Services
div(class="col-sm-9")
if successes
for success in successes
......@@ -50,13 +50,18 @@ html(lang="en")
div(class="form-row")
div(class='form-group col-md-2')
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)
option(value="Frau/Herr") Frau/Herr
option(value="Frau") Frau
option(value="Herr") Herr
option(value="Dr.") 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')
label(for="firstname") Vorname
input#inputFirstname(name="inputFirstname", type="text", class="form-control", placeholder="Vorname", value=user.firstname required)
......@@ -87,4 +92,5 @@ html(lang="en")
// Bootstrap
script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous")
// M4_LAB
script(src="/js/headfoot.js")
script(src="https://transfer.hft-stuttgart.de/js/headfoot.js")
......@@ -37,9 +37,9 @@ html(lang="en")
h5
span #{user.firstName} #{user.lastName}
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="/account/services" aria-selected="false") Services
a(class="nav-link" href="/services" aria-selected="false") Services
div(class="col-sm-9")
if successes
for success in successes
......@@ -49,7 +49,7 @@ html(lang="en")
for error, i in errors
div.alert.alert-danger.alert-dismissible.fade.show #{ error }
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")
label(for="currPwd") Current Password
input(id="inputCurrPwd", name="inputCurrPwd", type="password", class="form-control" required)
......@@ -72,9 +72,9 @@ html(lang="en")
// Bootstrap
script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous")
// M4_LAB
script(src="/account/js/security.js")
script(src="/account/js/generalFunction.js")
script(src="/js/headfoot.js")
script(src="/js/security.js")
script(src="/js/generalFunction.js")
script(src="https://transfer.hft-stuttgart.de/js/headfoot.js")
script.
// check input fields
'use strict';
......
......@@ -34,8 +34,8 @@ html(lang="en")
h5
span #{user.firstName} #{user.lastName}
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="/account/security" aria-selected="false") Security
a(class="nav-link" href="/profile" aria-selected="true") Profile
a(class="nav-link" href="/security" aria-selected="false") Security
a(class="nav-link" href="#" aria-selected="false") Services
div(class="col-sm-9")
if successes
......@@ -60,4 +60,4 @@ html(lang="en")
// Bootstrap
script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous")
// M4_LAB
script(src="/js/headfoot.js")
\ No newline at end of file
script(src="https://transfer.hft-stuttgart.de/js/headfoot.js")
\ 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