fix SMTP configuration

This commit is contained in:
lesion
2022-07-18 10:05:59 +02:00
parent 9e86a9399b
commit 92c676622d
9 changed files with 16 additions and 30 deletions

View File

@@ -21,7 +21,7 @@ const Auth = {
})
},
isAuth (req, res, next) {
isAuth (_req, res, next) {
if (res.locals.user) {
next()
} else {

View File

@@ -171,6 +171,10 @@ const settingsController = {
}
},
getSMTPSettings (_req, res) {
return res.json(settingsController['settings']['smtp'])
},
setLogo (req, res) {
if (!req.file) {
settingsController.set('logo', false)

View File

@@ -140,6 +140,7 @@ if (config.status !== 'READY') {
api.post('/settings', isAdmin, settingsController.setRequest)
api.post('/settings/logo', isAdmin, multer({ dest: config.upload_path }).single('logo'), settingsController.setLogo)
api.post('/settings/smtp', isAdmin, settingsController.testSMTP)
api.get('/settings/smtp', isAdmin, settingsController.getSMTPSettings)
// get unconfirmed events
api.get('/event/unconfirmed', isAdmin, eventController.getUnconfirmed)

View File

@@ -12,7 +12,7 @@ const oauthServer = new OAuthServer({
debug: true,
requireClientAuthentication: { password: false },
authenticateHandler: {
handle (req, res) {
handle (_req, res) {
if (!res.locals.user) {
throw new Error('Not authenticated!')
}

View File

@@ -69,24 +69,16 @@ module.exports = {
next()
},
async initSettings (req, res, next) {
async initSettings (_req, res, next) {
// initialize settings
res.locals.settings = cloneDeep(settingsController.settings)
if (res.locals.settings.smtp && res.locals.settings.smtp.auth) {
if (res.locals.user && res.locals.user.is_admin) {
delete res.locals.settings.smtp.auth.pass
} else {
delete res.locals.settings.smtp
}
}
delete res.locals.settings.smtp
delete res.locals.settings.publicKey
res.locals.settings.baseurl = config.baseurl
res.locals.settings.hostname = config.hostname
res.locals.settings.title = res.locals.settings.title || config.title
res.locals.settings.description = res.locals.settings.description || config.description
res.locals.settings.version = pkg.version
// set user locale
res.locals.user_locale = settingsController.user_locale[res.locals.acceptedLocale]
next()

View File

@@ -74,7 +74,7 @@ app.use((error, _req, res, _next) => {
// remaining request goes to nuxt
// first nuxt component is ./pages/index.vue (with ./layouts/default.vue)
// prefill current events, tags, places and announcements (used in every path)
app.use(async (req, res, next) => {
app.use(async (_req, res, next) => {
if (config.status === 'READY') {
const announceController = require('./api/controller/announce')
@@ -86,14 +86,5 @@ app.use(async (req, res, next) => {
module.exports = {
handler: app,
load () {
console.error('dentro load !')
},
unload: () => initialize.shutdown(false)
// async unload () {
// const db = require('./api/models/index')
// await db.close()
// process.off('SIGTERM')
// process.off('SIGINT')
// }
}