diff --git a/middlewares/authorization.js b/middlewares/authorization.js index 09495c8..382acbd 100644 --- a/middlewares/authorization.js +++ b/middlewares/authorization.js @@ -52,13 +52,16 @@ module.exports = { if(variables.authOidcEnabled) { oidc = req.oidc.isAuthenticated(); - // Retrieve user info/verify user session is still valid - req.user = await req.oidc.fetchUserInfo().catch(() => { - res.redirect(302, `${req.headers['x-ingress-path'] ? req.headers['x-ingress-path'] : ''}/login`); - }); + // Check if OIDC is used to authenticate + if(oidc) { + // Retrieve user info/verify user session is still valid + req.user = await req.oidc.fetchUserInfo().catch(() => { + res.redirect(302, `${req.headers['x-ingress-path'] ? req.headers['x-ingress-path'] : ''}/login`); + }); - if(!req.user) { - return; + if (!req.user) { + return; + } } } diff --git a/modules/mail.js b/modules/mail.js index 19d5931..f22d1b1 100644 --- a/modules/mail.js +++ b/modules/mail.js @@ -20,20 +20,31 @@ const time = require('../utils/time'); const bytes = require('../utils/bytes'); /** - * Create nodemailer transport + * Base SMTP config */ -const transport = nodemailer.createTransport({ +const smtpConfig = { host: variables.smtpHost, port: parseInt(variables.smtpPort), secure: variables.smtpSecure, tls: { rejectUnauthorized: false // Skip TLS Certificate checks for Self-Hosted systems - }, - auth: { + } +}; + +/** + * Include SMTP auth if defined + */ +if(variables.smtpUsername !== '' && variables.smtpPassword !== '') { + smtpConfig.auth = { user: variables.smtpUsername, pass: variables.smtpPassword - } -}); + }; +} + +/** + * Create nodemailer transport + */ +const transport = nodemailer.createTransport(smtpConfig); /** * Mail module functions diff --git a/package.json b/package.json index 7ca286b..592a350 100644 --- a/package.json +++ b/package.json @@ -17,21 +17,21 @@ "dependencies": { "cookie-parser": "^1.4.7", "ejs": "^3.1.10", - "express": "^5.1.0", + "express": "^5.2.0", "express-locale": "^2.0.2", - "express-openid-connect": "^2.19.2", + "express-openid-connect": "^2.19.3", "js-logger": "^1.6.1", "jsonwebtoken": "^9.0.2", "multer": "^2.0.2", "node-thermal-printer": "^4.5.0", - "nodemailer": "^7.0.10", + "nodemailer": "^7.0.11", "pdfkit": "^0.17.2", "qrcode": "^1.5.4", "undici": "^7.16.0" }, "devDependencies": { - "@tailwindcss/cli": "^4.1.16", + "@tailwindcss/cli": "^4.1.17", "@tailwindcss/forms": "^0.5.10", - "tailwindcss": "^4.1.16" + "tailwindcss": "^4.1.17" } }