diff --git a/routes/routes.js b/routes/routes.js index 64cfe7b6076816eb5b7cf6c1cecb11c178d75df0..7c0addb38550fdcdbb85a73d273ca9b1704a91a2 100644 --- a/routes/routes.js +++ b/routes/routes.js @@ -54,15 +54,37 @@ module.exports = function (app, config, passport) { passport.use(samlStrategy); + // ============================ +/* + app.all('/', function(req, res){ + req.flash('test', 'it worked'); + res.redirect('/test') + }); + app.all('/test', function(req, res){ + 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: '/', + failureRedirect: '/account/', failureFlash: true }), function (req, res) { - res.redirect('/'); + res.redirect('/account/'); } ); @@ -399,7 +421,7 @@ module.exports = function (app, config, passport) { if (user) { // encrypt password bcrypt.genSalt(saltRounds, function(err, salt) { - bcrypt.hash(req.body.inputNewPwd, salt, function(err, hash) { + bcrypt.hash(newPwd, salt, function(err, hash) { var credentialData = { password: hash, user_id: user.user_id @@ -427,27 +449,9 @@ module.exports = function (app, config, passport) { res.redirect('/account/login') }); - // todo: user registration with captcha - app.get('/registration', function(req, res) { - res.render('registration') - }) - - app.post('/registration', function(req, res) { - // TODO: - // create gitlab account? - // send email to activate profile? - - // user data - var curDate = new Date() - var userData = { - 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) + app.get('/logout', function (req, res) { + if (req.user == null) { + return res.redirect('/account/'); } // encrypt password bcrypt.genSalt(saltRounds, function(err, salt) { diff --git a/views/profile.pug b/views/profile.pug index 51d31093396d8db07c7560f0c86bacaa3c6c4caa..94e9500aa14e2c18107b2dce46f004e689ebf3c8 100644 --- a/views/profile.pug +++ b/views/profile.pug @@ -87,5 +87,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="/account/js/account.js") script(src="/js/headfoot.js")