Commit 69511069 authored by Wolfgang Knopki's avatar Wolfgang Knopki
Browse files

set paths to relative instead of global

parent 965a24d9
Pipeline #343 passed with stage
in 8 seconds
......@@ -63,40 +63,40 @@ module.exports = function (app, config, passport) {
res.send(JSON.stringify(req.flash('test')));
});
*/
app.get('/', function (req, res) {
res.redirect('/profile')
app.get('./', function (req, res) {
res.redirect('./profile')
});
app.get('/login',
app.get('./login',
passport.authenticate(config.passport.strategy,
{
successRedirect: '/',
failureRedirect: '/login'
successRedirect: './',
failureRedirect: './login'
})
);
app.post(config.passport.saml.path,
passport.authenticate(config.passport.strategy,
{
failureRedirect: '/',
failureRedirect: './',
failureFlash: true
}),
function (req, res) {
res.redirect('/');
res.redirect('./');
}
);
app.get('/profile', function (req, res) {
app.get('./profile', function (req, res) {
if (req.isAuthenticated()) {
res.render('profile', {
user: req.user // useful for view engine, useless for HTML
});
} else {
res.redirect('/login');
res.redirect('./login');
}
});
app.get('/services', function (req, res) {
app.get('./services', function (req, res) {
if (req.isAuthenticated()) {
async.waterfall([
// get userId by email from userdb
......@@ -156,21 +156,21 @@ module.exports = function (app, config, passport) {
}
])
} else {
res.redirect('/login');
res.redirect('./login');
}
});
app.get('/security', function (req, res) {
app.get('./security', function (req, res) {
if (req.isAuthenticated()) {
res.render('security', {
user: req.user // useful for view engine, useless for HTML
});
} else {
res.redirect('/login');
res.redirect('./login');
}
});
app.post('/updateProfile', function (req, res) {
app.post('./updateProfile', function (req, res) {
var userData = {
title: req.body.inputTitle,
firstname: req.body.inputFirstname,
......@@ -195,13 +195,13 @@ module.exports = function (app, config, passport) {
})
}
} else {
res.redirect('/login');
res.redirect('./login');
}
});
// todo: user registration with captcha
app.post('/changePwd', function (req, res) {
app.post('./changePwd', function (req, res) {
if (req.isAuthenticated()) {
var currPwd = req.body.inputCurrPwd
var newPwd = req.body.inputNewPwd
......@@ -210,7 +210,7 @@ module.exports = function (app, config, passport) {
// Load hashed passwd from DB.
dbconn.user.query('SELECT password FROM user WHERE email="'+req.user.email+'"', function (err, rows, fields) {
if (err) {
res.redirect('/500')
res.redirect('./500')
throw err
}
var userPwd = rows[0].password
......@@ -218,16 +218,16 @@ module.exports = function (app, config, passport) {
// check if the password is correct
bcrypt.compare(currPwd, userPwd, function(err, isMatch) {
if (err) {
res.redirect('/500')
res.redirect('./500')
throw err
}
else if (!isMatch) {
req.flash('error', "Sorry, your password was incorrect. Please double-check your password.")
res.redirect('/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('/security')
res.redirect('./security')
}
else {
// update password
......@@ -242,7 +242,7 @@ module.exports = function (app, config, passport) {
req.flash('success', "Pasword updated!")
console.log('pasword updated!')
}
res.redirect('/security')
res.redirect('./security')
})
});
});
......@@ -251,11 +251,11 @@ module.exports = function (app, config, passport) {
})
})
} else {
res.redirect('/login');
res.redirect('./login');
}
});
app.get('/forgotPwd', function (req, res) {
app.get('./forgotPwd', function (req, res) {
res.render('forgotPwd', {
user: req.user
});
......@@ -284,7 +284,7 @@ module.exports = function (app, config, passport) {
text: ""
};
app.post('/forgotPwd', function(req, res, next) {
app.post('./forgotPwd', function(req, res, next) {
//methods.currentDate();
/* do something: write down reset password procedure in Technical Req. Document
ref: https://meanstackdeveloper.in/implement-reset-password-functionality-in-node-js-express.html
......@@ -345,16 +345,16 @@ module.exports = function (app, config, passport) {
else {
req.flash('success', 'An e-mail has been sent to ' + emailAddress + ' with further instructions.');
}
res.redirect('/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){
//console.log(user);
if (!user) {
req.flash('error', 'Password reset token is invalid or has expired.');
res.redirect('/forgotPwd');
res.redirect('./forgotPwd');
}
else {
res.render('reset');
......@@ -362,7 +362,7 @@ module.exports = function (app, config, passport) {
});
});
app.post('/reset/:token', function(req, res) {
app.post('./reset/:token', function(req, res) {
methods.checkUserToken(req.params.token, function(err, user){
if (user) {
// update password
......@@ -387,12 +387,12 @@ module.exports = function (app, config, passport) {
}
});
res.redirect('/login')
res.redirect('./login')
});
app.get('/logout', function (req, res) {
app.get('./logout', function (req, res) {
if (req.user == null) {
return res.redirect('/');
return res.redirect('./');
}
req.user.nameID = req.user.id;
......@@ -414,7 +414,7 @@ module.exports = function (app, config, passport) {
});
// to generate Service Provider's XML metadata
app.get('/saml/metadata',
app.get('./saml/metadata',
function(req, res) {
res.type('application/xml');
var spMetadata = samlStrategy.generateServiceProviderMetadata(fs.readFileSync(__dirname + '/cert/cert.pem', 'utf8'));
......
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