Commit a1499b82 authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files
parents 6f364054 5140687d
......@@ -62,26 +62,26 @@ module.exports = function (app, config, passport, i18n) {
failureFlash: true
}),
function (req, res) {
res.redirect('/account/');
res.redirect('/');
}
);
// 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'));
res.status(200).send(spMetadata);
}
);
// ================ test i18n ==================
i18n.setLocale('de');
app.get('/de', function(req, res) {
var greeting = i18n.__('Hello World')
res.send(greeting)
});
var lang = 'DE'
// ======== APP ROUTES - ACCOUNT ====================
......@@ -104,8 +104,8 @@ module.exports = function (app, config, passport, i18n) {
}
})
} else {
res.redirect('/account/login'); // localhost
}
res.redirect('/login'); // localhost
}
});
app.get('/error', function (req, res) {
......@@ -122,14 +122,14 @@ module.exports = function (app, config, passport, i18n) {
app.get('/logout', function (req, res) {
if (req.user == null) {
return res.redirect('/account/');
return res.redirect('/');
}
req.user.nameID = req.user.id;
req.user.nameIDFormat = req.user.idFormat;
return samlStrategy.logout(req, function(err, uri) {
req.logout();
if ( req.session ) {
req.session.destroy((err) => {
if(err) {
......@@ -137,7 +137,7 @@ module.exports = function (app, config, passport, i18n) {
}
});
}
return res.redirect(uri);
});
});
......@@ -153,7 +153,7 @@ module.exports = function (app, config, passport, i18n) {
}
})
} else {
res.redirect('/account/login');
res.redirect('/login');
}
});
......@@ -187,7 +187,7 @@ module.exports = function (app, config, passport, i18n) {
// create JSON object of projects and user status for front-end
function(userProjects, projectsOverview, done) {
var allProjects = [] // JSON object
var userProjectId = [] // array of user's project_id
for (var i = 0; i < userProjects.length; i++) {
userProjectId.push(userProjects[i].project_id)
......@@ -217,7 +217,7 @@ module.exports = function (app, config, passport, i18n) {
}
])
} else {
res.redirect('/account/login');
res.redirect('/login');
}
});
......@@ -227,7 +227,7 @@ module.exports = function (app, config, passport, i18n) {
user: req.user // useful for view engine, useless for HTML
});
} else {
res.redirect('/account/login');
res.redirect('/login');
}
});
......@@ -242,7 +242,7 @@ module.exports = function (app, config, passport, i18n) {
industry: req.body.inputIndustry,
speciality: req.body.inputSpeciality,
}
if (req.isAuthenticated()) {
if (userData.email) {
dbconn.user.query('UPDATE user SET ? WHERE email = "' +userData.email+'"', userData, function (err, rows, fields) {
......@@ -257,10 +257,10 @@ module.exports = function (app, config, passport, i18n) {
})
}
} else {
res.redirect('/account/login');
res.redirect('/login');
}
});
app.post('/changePwd', function (req, res) {
if (req.isAuthenticated()) {
var currPwd = req.body.inputCurrPwd
......@@ -272,7 +272,7 @@ module.exports = function (app, config, passport, i18n) {
// 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
......@@ -280,14 +280,14 @@ module.exports = function (app, config, passport, i18n) {
// check if the password is correct
bcrypt.compare(currPwd, userPwd, function(err, isMatch) {
if (err) {
res.redirect('/account/500')
res.redirect('/500')
throw err
}
else if (!isMatch) {
//req.flash('error', "Sorry, your password was incorrect. Please double-check your password.")
req.flash('error', "Das Passwort ist leider falsch. Bitte überprüfen Sie Ihre Eingabe.")
//res.redirect('/account/security')
res.redirect('/account/security')
//res.redirect('/security')
res.redirect('/security')
}
else {
if ( newPwd != retypePwd ) {
......@@ -321,19 +321,19 @@ module.exports = function (app, config, passport, i18n) {
}
});
}
res.redirect('/account/security')
res.redirect('/security')
})
});
});
}
}
})
})
})
}
})
})
}
else {
res.redirect('/account/login');
res.redirect('/login');
}
});
......@@ -351,7 +351,7 @@ module.exports = function (app, config, passport, i18n) {
"we've received a request to reset your password. However, this email address is not on our database of registered users.\n\n"+
"Thanks,\nM4_LAB Team";
var emailSubject = "Account Access Attempted"; */
async.waterfall([
function(done) {
crypto.randomBytes(20, function(err, buf) {
......@@ -408,8 +408,8 @@ module.exports = function (app, config, passport, i18n) {
//req.flash('success', 'If your email is registered, an e-mail has been sent to ' + emailAddress + ' with further instructions.');
req.flash('success', 'Wenn Ihre E-Mail-Adresse registriert ist, wurde eine E-Mail mit dem weiteren Vorgehen an ' + emailAddress + ' versendet.');
}
//res.redirect('/account/forgotPwd'); // deployment
res.redirect('/account/forgotPwd'); // localhost
//res.redirect('/forgotPwd'); // deployment
res.redirect('/forgotPwd'); // localhost
});
});
......@@ -418,8 +418,8 @@ module.exports = function (app, config, passport, i18n) {
if (!user) {
//req.flash('error', 'Password reset token is invalid or has expired.');
req.flash('error', 'Der Schlüssel zum zurücksetzen des Passworts ist ungültig oder abgelaufen.');
//res.redirect('/account/forgotPwd'); // deployment
res.redirect('/account/forgotPwd'); // localhost
//res.redirect('/forgotPwd'); // deployment
res.redirect('/forgotPwd'); // localhost
}
else {
res.render(lang+'/account/reset');
......@@ -428,7 +428,7 @@ module.exports = function (app, config, passport, i18n) {
});
app.post('/reset/:token', function(req, res) {
var newPwd = req.body.inputNewPwd
var newPwd = req.body.inputNewPwd
methods.getUserByToken(req.params.token, function(err, user){
if (user) {
// encrypt password
......@@ -458,7 +458,7 @@ module.exports = function (app, config, passport, i18n) {
}
});
// redirect to login page
res.redirect('/account/login')
res.redirect('/login')
}
})
});
......@@ -466,10 +466,10 @@ module.exports = function (app, config, passport, i18n) {
}
else {
req.flash('error', "User not found.")
res.redirect('/account/login')
res.redirect('/login')
}
});
});
// todo: user registration with captcha
......@@ -510,9 +510,9 @@ module.exports = function (app, config, passport, i18n) {
}
else {
//req.flash('success', 'Your account has been created. Please log in.')
req.flash('success', 'Ihr Benutzerkonto wurde angelegt. Bitte melden Sie sich an.')
req.flash('success', 'Ihr Benutzerkonto wurde angelegt. Bitte melden Sie sich an.')
}
res.redirect('/account/registration');
res.redirect('/registration');
})
});
});
......
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