diff --git a/app.js b/app.js index a291b73..13a0175 100644 --- a/app.js +++ b/app.js @@ -9,7 +9,7 @@ const moment=require('moment') require('dotenv').config(); const app = express(); -const port = 2000; +const port = 2001; // Middleware app.use(express.static(path.join(__dirname, 'public'))); @@ -19,7 +19,7 @@ app.use(express.urlencoded({ extended: false })); // Session-Konfiguration app.use(session({ - secret: 'your_secret_key', + secret: process.env.SESSIONSECRET, resave: false, saveUninitialized: false, cookie: { maxAge: 1800000 } @@ -42,12 +42,12 @@ const requireAdmin = (req, res, next) => { // Email-Konfiguration const transporter = nodemailer.createTransport({ - host: "mail.boergmann.it", + host: process.env.MAILHOST, port: 465, secure: true, auth: { - user: 'klaas@boergmann.it', - pass: 'XDsEXTdAUVkH5=V' + user: process.env.MAILUSER, + pass: process.env.MAILPASS } }); @@ -356,6 +356,22 @@ app.post('/profile', requireAuth, async (req, res) => { } }); +app.post('/update-training', async (req, res) => { + const { trainingId, type, spielId } = req.body; + + try { + if (type === 'spiel') { + await pool.query('UPDATE trainings SET spiel = $1 WHERE id = $2', [spielId, trainingId]); + } else if (type === 'aufwaermen') { + await pool.query('UPDATE trainings SET aufwaermen = $1 WHERE id = $2', [spielId, trainingId]); + } + res.redirect('/'); + } catch (err) { + console.error(err); + res.send("Error " + err); + } +}); + app.post('/update-leader', async (req, res) => { const { trainingId, type, leaderId } = req.body; diff --git a/views/trainings.ejs b/views/trainings.ejs index d3f396b..d6aeef3 100644 --- a/views/trainings.ejs +++ b/views/trainings.ejs @@ -1,8 +1,8 @@ <%- include('partials/header') %> -

Trainings

+

Training <%= training.datum %>

- +
<% if (training) { %> -