From 8bedc51ff337d4e00d3a5c4114e196626c9c901e Mon Sep 17 00:00:00 2001 From: Wolfgang Knopki <wolfgang.knopki@hft-stuttgart.de> Date: Thu, 19 Mar 2020 11:19:16 +0100 Subject: [PATCH] cleanup merge --- routes/routes-account.js | 168 +-------------------------------------- routes/routes-project.js | 6 +- 2 files changed, 6 insertions(+), 168 deletions(-) diff --git a/routes/routes-account.js b/routes/routes-account.js index 7984d39e..16bf5c8c 100644 --- a/routes/routes-account.js +++ b/routes/routes-account.js @@ -9,7 +9,7 @@ const salt = 64; // salt length // forgot pwd const async = require('async') const crypto = require('crypto') -const nodemailer = require('nodemailer') +const nodemailer = require('./mailer') module.exports = function (app, config, passport, i18n) { @@ -75,27 +75,6 @@ module.exports = function (app, config, passport, i18n) { } ); - // ======== NODEMAILER ==================== - var smtpTransport = nodemailer.createTransport({ - host: config.mailer.host, - secureConnection: config.mailer.secureConnection, - port: config.mailer.port, - auth: { - user: config.mailer.authUser, - pass: config.mailer.authPass - }, - tls: { - ciphers: config.mailer.tlsCiphers - } - }); - - var mailOptions = { - to: "", - from: config.mailer.from, - subject: "", - text: "" - }; - var updatePasswordMailSubject = "Ihr Passwort für das Transferportal wurde gespeichert." var mailSignature = "Mit den besten Grüßen,\ndas Transferportal-Team der HFT Stuttgart\n\n"+ "Transferportal der Hochschule für Technik Stuttgart\n"+ @@ -274,7 +253,7 @@ module.exports = function (app, config, passport, i18n) { else { req.flash('success', 'Profile updated!'); } - res.redirect('lang+/account/profile'); + res.redirect('/account/profile'); }) } } else { @@ -313,7 +292,7 @@ module.exports = function (app, config, passport, i18n) { else { if ( newPwd != retypePwd ) { req.flash('error', "Passwords do no match. Please make sure you re-type your new password correctly.") - res.redirect(lang+'/account/security') + res.redirect('/account/security') } else { // update password @@ -551,146 +530,5 @@ module.exports = function (app, config, passport, i18n) { } }) }) - app.get('/mailinglists', function (req, res) { - async.waterfall([ - function(done) { - methods.getAllMailinglists(function(mailinglistOverview, err) { - if (!err) { - done(err, mailinglistOverview) - } - }) - }, - // create JSON object of mailinglists for front-end - function(mailinglistOverview, done) { - var allMailingLists = [] // JSON object - for (let i = 0; i < mailinglistOverview.length; i++) { - // add data to JSON object - allMailingLists.push({ - id: mailinglistOverview[i].id, - name: mailinglistOverview[i].name, - src: mailinglistOverview[i].src, - projectstatus: mailinglistOverview[i].projectstatus, - project_title: mailinglistOverview[i].project_title - }); - } - - res.render(lang+'/mailinglists', { - isUserAuthenticated: req.isAuthenticated(), - user: req.user, - mailinglists: allMailingLists - }); - } - ]) - }); - - // ======== APP ROUTES - PROJECT ==================== - app.get('/project', function (req, res) { - async.waterfall([ - // get all projects from projectdb - function(done) { - methods.getAllProjects(function(projectsOverview, err) { - if (!err) { - done(err, projectsOverview) - } - }) - }, - // create JSON object for front-end - function(projectsOverview, done) { - var activeProjects = [] - var nonActiveProjects = [] - - for (var i = 0; i < projectsOverview.length; i++) { - var project = { - id: projectsOverview[i].id, - logo: projectsOverview[i].logo, - akronym: projectsOverview[i].pname, - title: projectsOverview[i].title, - summary: projectsOverview[i].onelinesummary, - category: projectsOverview[i].category, - cp: projectsOverview[i].contact_email, - gitlab: projectsOverview[i].gitlab - } - if (projectsOverview[i].projectstatus == 0) { - nonActiveProjects.push(project) - } - else if (projectsOverview[i].projectstatus == 1) { - activeProjects.push(project) - } - } - - // render the page - if (req.isAuthenticated()) { - res.render(lang+'/project/projects', { - isUserAuthenticated: true, - nonActive: nonActiveProjects, - active: activeProjects - }); - } - else { - res.render(lang+'/project/projects', { - isUserAuthenticated: false, - nonActive: nonActiveProjects, - active: activeProjects - }); - } - } - ]) - }) - - app.get('/addprojectoverview', function (req, res) { - if (req.isAuthenticated()) { - res.render(lang+'/project/addProjectOverview') - } - else { - res.redirect('/account/login') - } - }) - - app.post('/addprojectoverview', function (req, res) { - if (req.isAuthenticated()) { - var wiki = 0 - if (req.body.wiki) - wiki = 1 - - var projectOverviewData = { - pname: req.body.pname, - title: req.body.title, - onelinesummary: req.body.summary, - category: req.body.category, - logo: req.body.logo, - gitlab: req.body.gitlabURL, - wiki: wiki, - overview: req.body.overview, - question: req.body.question, - approach: req.body.approach, - result: req.body.result, - keywords: req.body.keywords, - announcement: req.body.announcement, - term: req.body.term, - further_details: req.body.furtherDetails, - website: req.body.website, - src: req.body.src, - caption: req.body.caption, - contact_firstname: req.body.contactFirstname, - contact_lastname: req.body.contactLastname, - contact_email: req.body.contactEmail, - leader_firstname: req.body.leaderFirstname, - leader_lastname: req.body.leaderLastname, - leader_email: req.body.leaderEmail - } - - methods.addProjectOverview(projectOverviewData, function(err){ - if (err) { - //req.flash('error', "Failed") - req.flash('error', "Fehlgeschlagen") - res.redirect('/account/addProjectOverview'); - } - else { - req.flash('success', 'Your project has been created.') - res.redirect('/account/project'); - } - }) - } - }) }; \ No newline at end of file diff --git a/routes/routes-project.js b/routes/routes-project.js index f68aecdc..bea8584c 100644 --- a/routes/routes-project.js +++ b/routes/routes-project.js @@ -100,7 +100,7 @@ module.exports = function (app) { } }) - app.post('/addprojectoverview', function (req, res) { + app.post('/addprojectoverview__', function (req, res) { if (req.isAuthenticated()) { var wiki = 0 if (req.body.wiki) @@ -136,7 +136,7 @@ module.exports = function (app) { if (err) { //req.flash('error', "Failed") req.flash('error', "Fehlgeschlagen") - res.redirect('/addProjectOverview'); + res.redirect('/account/addProjectOverview'); } else { req.flash('success', 'Your project has been created.') @@ -211,7 +211,7 @@ module.exports = function (app) { if (err) { //req.flash('error', "Failed") req.flash('error', "Fehlgeschlagen") - res.redirect('/addProjectOverview'); + res.redirect('/account/addProjectOverview'); } else { req.flash('success', 'Your project has been created.') -- GitLab