Commit 1f659fc8 authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

remove unused variables

parent 74e11d71
...@@ -13,15 +13,9 @@ const helmet = require('helmet'); ...@@ -13,15 +13,9 @@ const helmet = require('helmet');
const compression = require('compression'); const compression = require('compression');
const methodOverride = require('method-override'); const methodOverride = require('method-override');
const i18n = require('i18n'); // internationalization
i18n.configure({
locales:['de', 'en'],
directory: './locales'
});
const lang = 'DE'
var env = process.env.NODE_ENV || 'testing'; var env = process.env.NODE_ENV || 'testing';
const config = require('./config/config')[env]; const config = require('./config/config')[env];
const lang = 'DE';
var app = express(); var app = express();
...@@ -45,9 +39,7 @@ app.use(cookieParser()); ...@@ -45,9 +39,7 @@ app.use(cookieParser());
app.use(bodyParser.json()); app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.urlencoded({extended: false}));
app.use(express.static(path.join(__dirname, 'public'))); app.use(express.static(path.join(__dirname, 'public')));
app.use(i18n.init);
app.use((req, res, next) => { app.use((req, res, next) => {
res.setLocale('de');
next(); next();
}); });
...@@ -69,18 +61,18 @@ app.use(function(req, res, next) { ...@@ -69,18 +61,18 @@ app.use(function(req, res, next) {
next(); next();
}); });
require('./routes/routes-account')(app, config, passport, i18n); require('./routes/routes-account')(app, config, passport, lang);
require('./routes/public')(app, config, lang); require('./routes/public')(app, config, lang);
// Handle 404 // Handle 404
app.use(function (req, res) { app.use(function (req, res) {
res.status(404).render('DE/404') res.status(404).render(lang+'/404')
}) })
// Handle 500 - any server error // Handle 500 - any server error
app.use(function (err, req, res, next) { app.use(function (err, req, res, next) {
console.error(err.stack) console.error(err.stack)
res.status(500).render('DE/500', { res.status(500).render(lang+'/500', {
error: err error: err
}) })
}) })
......
...@@ -3,6 +3,7 @@ const SamlStrategy = require('passport-saml').Strategy ...@@ -3,6 +3,7 @@ const SamlStrategy = require('passport-saml').Strategy
const dbconn = require('../config/dbconn') const dbconn = require('../config/dbconn')
const methods = require('../functions/methods') const methods = require('../functions/methods')
const gitlab = require('../functions/gitlab') const gitlab = require('../functions/gitlab')
const constants = require('../config/const')
// pwd encryption // pwd encryption
const bcrypt = require('bcryptjs'); const bcrypt = require('bcryptjs');
const saltRounds = 10; const saltRounds = 10;
...@@ -20,7 +21,7 @@ const portalUser = require('../classes/user') ...@@ -20,7 +21,7 @@ const portalUser = require('../classes/user')
const projectInformation = require('../classes/website') const projectInformation = require('../classes/website')
const projectRepo = require('../classes/repo') const projectRepo = require('../classes/repo')
module.exports = function (app, config, passport, i18n) { module.exports = function (app, config, passport, lang) {
// =========== PASSPORT ======= // =========== PASSPORT =======
passport.serializeUser(function (user, done) { passport.serializeUser(function (user, done) {
...@@ -31,20 +32,6 @@ module.exports = function (app, config, passport, i18n) { ...@@ -31,20 +32,6 @@ module.exports = function (app, config, passport, i18n) {
done(null, user); done(null, user);
}); });
const mailSignature = 'Mit den besten Grüßen,<br/>das Transferportal-Team der HFT Stuttgart<br/><br/>' +
'Transferportal der Hochschule für Technik Stuttgart<br/>' +
'Schellingstr. 24 70174 Stuttgart<br/>' +
'm4lab@hft-stuttgart.de<br/>' +
'<a href="https://transfer.hft-stuttgart.de">https://transfer.hft-stuttgart.de</a><br/>' +
'<a href="http://www.hft-stuttgart.de/Aktuell/"><img border="0" alt="HFT" src="https://m4lab.hft-stuttgart.de/img/signature/hft_logo.png" width="30" height="30"></a> &nbsp;' +
'<a href="http://www.facebook.com/hftstuttgart"><img border="0" alt="Facebook" src="https://m4lab.hft-stuttgart.de/img/signature/fb_bw.png" width="30" height="30"></a> &nbsp;' +
'<a href="https://www.instagram.com/hft_stuttgart/"><img border="0" alt="Instagram" src="https://m4lab.hft-stuttgart.de/img/signature/instagram_bw.png" width="30" height="30"></a> &nbsp;' +
'<a href="https://twitter.com/hft_presse"><img border="0" alt="Twitter" src="https://m4lab.hft-stuttgart.de/img/signature/twitter_bw.png" width="30" height="30"></a> &nbsp;' +
'<a href="https://www.youtube.com/channel/UCi0_JfF2qMZbOhOnNH5PyHA"><img border="0" alt="Youtube" src="https://m4lab.hft-stuttgart.de/img/signature/youtube_bw.png" width="30" height="30"></a> &nbsp;' +
'<a href="http://www.hft-stuttgart.de/Aktuell/Presse-Marketing/SocialMedia/Snapcode HFT_Stuttgart.jpg/photo_view">' +
'<img border="0" alt="Snapchat" src="https://m4lab.hft-stuttgart.de/img/signature/snapchat_bw.png" width="30" height="30"></a>' +
'<br/><img border="0" src="https://m4lab.hft-stuttgart.de/img/signature/inno_bw.png" width="150" height="100">'
var samlStrategy = new SamlStrategy({ var samlStrategy = new SamlStrategy({
// URL that goes from the Identity Provider -> Service Provider // URL that goes from the Identity Provider -> Service Provider
callbackUrl: config.passport.saml.path, callbackUrl: config.passport.saml.path,
...@@ -98,18 +85,9 @@ module.exports = function (app, config, passport, i18n) { ...@@ -98,18 +85,9 @@ module.exports = function (app, config, passport, i18n) {
} }
); );
// ================ 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 ==================== // ======== APP ROUTES - ACCOUNT ====================
var updatePasswordMailSubject = "Ihr Passwort für das Transferportal wurde gespeichert." var updatePasswordMailSubject = "Ihr Passwort für das Transferportal wurde gespeichert."
var updatePasswordMailContent = '<div>Lieber Nutzer,<br/><br/>Ihr Passwort wurde erfolgreich geändert.<br/><br/>' + mailSignature + '</div>'; var updatePasswordMailContent = '<div>Lieber Nutzer,<br/><br/>Ihr Passwort wurde erfolgreich geändert.<br/><br/>' + constants.mailSignature + '</div>';
async function getLoggedInUserData(email) { async function getLoggedInUserData(email) {
let user = await methods.getUserByEmail(email) let user = await methods.getUserByEmail(email)
...@@ -374,15 +352,10 @@ module.exports = function (app, config, passport, i18n) { ...@@ -374,15 +352,10 @@ module.exports = function (app, config, passport, i18n) {
if (user) { if (user) {
console.log("email: user found"); console.log("email: user found");
var emailSubject = "Ihre Passwort-Anfrage an das Transferportal der HFT Stuttgart"; var emailSubject = "Ihre Passwort-Anfrage an das Transferportal der HFT Stuttgart";
// var emailContent = "Lieber Nutzer,\n\n"+ var emailContent = '<div>Lieber Nutzer,<br/><br/>' +
// "wir haben Ihre Anfrage zur Erneuerung Ihres Passwortes erhalten. Falls Sie diese Anfrage nicht gesendet haben, ignorieren Sie bitte diese E-Mail.\n\n"+
// "Sie können Ihr Passwort mit dem Klick auf diesen Link ändern: http://localhost:9989/reset/" + token + "\n" + // localhost
// "Dieser Link ist aus Sicherheitsgründen nur für 1 Stunde gültig.\n\n"+mailSignature
var emailContent = '<div>Lieber Nutzer, Varun<br/><br/>' +
'<p>wir haben Ihre Anfrage zur Erneuerung Ihres Passwortes erhalten. Falls Sie diese Anfrage nicht gesendet haben, ignorieren Sie bitte diese E-Mail.<br/><br/>' + '<p>wir haben Ihre Anfrage zur Erneuerung Ihres Passwortes erhalten. Falls Sie diese Anfrage nicht gesendet haben, ignorieren Sie bitte diese E-Mail.<br/><br/>' +
'Sie können Ihr Passwort mit dem Klick auf diesen Link ändern: http://m4lab.hft-stuttgart.de/account/reset/' + token + '<br/>' + // test server 'Sie können Ihr Passwort mit dem Klick auf diesen Link ändern: '+config.app.host+'/reset/' + token + '<br/>' +
'Dieser Link ist aus Sicherheitsgründen nur für 1 Stunde gültig.<br/></p>' + mailSignature + '</div>'; 'Dieser Link ist aus Sicherheitsgründen nur für 1 Stunde gültig.<br/></p>' + constants.mailSignature + '</div>';
var credentialData = { var credentialData = {
user_id: user.id, user_id: user.id,
...@@ -694,7 +667,7 @@ module.exports = function (app, config, passport, i18n) { ...@@ -694,7 +667,7 @@ module.exports = function (app, config, passport, i18n) {
var emailSubject = "Herzlich willkommen" var emailSubject = "Herzlich willkommen"
var emailContent = '<div>Lieber Nutzer,<br/><br/>' + var emailContent = '<div>Lieber Nutzer,<br/><br/>' +
'<p>herzlich willkommen beim Transferportal der HFT Stuttgart!<br/>' + '<p>herzlich willkommen beim Transferportal der HFT Stuttgart!<br/>' +
'Sie können nun alle Dienste des Portals nutzen.<p/><br/>' + mailSignature; 'Sie können nun alle Dienste des Portals nutzen.<p/><br/>' + constants.mailSignature;
mailer.options.to = data.email; mailer.options.to = data.email;
mailer.options.subject = emailSubject; mailer.options.subject = emailSubject;
mailer.options.html = emailContent; mailer.options.html = emailContent;
...@@ -732,15 +705,11 @@ module.exports = function (app, config, passport, i18n) { ...@@ -732,15 +705,11 @@ module.exports = function (app, config, passport, i18n) {
if (token) { if (token) {
// send email // send email
var emailSubject = "Bitte bestätigen Sie Ihr M4_LAB Benutzerkonto" var emailSubject = "Bitte bestätigen Sie Ihr M4_LAB Benutzerkonto"
// var emailContent = "Lieber Nutzer,\n\n"+
// "vielen Dank für Ihre Anmeldung am Transferportal der HFT Stuttgart. "+
// "\nUm Ihre Anmeldung zu bestätigen, klicken Sie bitte diesen Link: "+config.app.host+"/verifyAccount?token="+token+
// "\n\nOhne Bestätigung Ihres Kontos müssen wir Ihr Konto leider nach 7 Tagen löschen.\n\n"+mailSignature
var emailContent = '<div>Lieber Nutzer,<br/><br/>' + var emailContent = '<div>Lieber Nutzer,<br/><br/>' +
'<p>vielen Dank für Ihre Anmeldung am Transferportal der HFT Stuttgart. <br/>' + '<p>vielen Dank für Ihre Anmeldung am Transferportal der HFT Stuttgart. <br/>' +
'Um Ihre Anmeldung zu bestätigen, klicken Sie bitte diesen Link: ' + config.app.host + '/verifyAccount?token=' + token + 'Um Ihre Anmeldung zu bestätigen, klicken Sie bitte diesen Link: ' + config.app.host + '/verifyAccount?token=' + token +
'<br/><br/>' + '<br/><br/>' +
'Ohne Bestätigung Ihres Kontos müssen wir Ihr Konto leider nach 7 Tagen löschen.</p><br/>' + mailSignature + 'Ohne Bestätigung Ihres Kontos müssen wir Ihr Konto leider nach 7 Tagen löschen.</p><br/>' + constants.mailSignature +
'</div>'; '</div>';
mailer.options.to = emailAddress; mailer.options.to = emailAddress;
mailer.options.subject = emailSubject; mailer.options.subject = emailSubject;
......
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