fix SMTP configuration
This commit is contained in:
@@ -46,7 +46,6 @@ v-card
|
|||||||
import { mapActions, mapState } from 'vuex'
|
import { mapActions, mapState } from 'vuex'
|
||||||
export default {
|
export default {
|
||||||
data ({ $store }) {
|
data ({ $store }) {
|
||||||
const smtp = { auth: {}, ...$store.state.settings.smtp }
|
|
||||||
// if ($store.state.settings.smtp) {
|
// if ($store.state.settings.smtp) {
|
||||||
// smtp.host = $store.state.settings.smtp.host
|
// smtp.host = $store.state.settings.smtp.host
|
||||||
// if ($store.state.settings.smtp.auth) {
|
// if ($store.state.settings.smtp.auth) {
|
||||||
@@ -59,10 +58,13 @@ export default {
|
|||||||
return {
|
return {
|
||||||
isValid: false,
|
isValid: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
smtp,
|
smtp: { auth: {} },
|
||||||
admin_email: $store.state.settings.admin_email || ''
|
admin_email: $store.state.settings.admin_email || ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async fetch () {
|
||||||
|
this.smtp = await this.$axios.$get('/settings/smtp')
|
||||||
|
},
|
||||||
computed: mapState(['settings']),
|
computed: mapState(['settings']),
|
||||||
watch: {
|
watch: {
|
||||||
'smtp.secure' (value) {
|
'smtp.secure' (value) {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ v-container
|
|||||||
|
|
||||||
v-card-actions
|
v-card-actions
|
||||||
v-btn(text @click='showSMTP=true')
|
v-btn(text @click='showSMTP=true')
|
||||||
<v-icon v-if='showSMTPAlert' color='error' v-text='mdiAlert'></v-icon> {{$t('admin.show_smtp_setup')}}
|
<v-icon v-if='!settings.admin_email' color='error' v-text='mdiAlert'></v-icon> {{$t('admin.show_smtp_setup')}}
|
||||||
v-btn(text @click='$emit("complete")' color='primary' v-if='setup') {{$t('common.next')}}
|
v-btn(text @click='$emit("complete")' color='primary' v-if='setup') {{$t('common.next')}}
|
||||||
v-icon(v-text='mdiArrowRight')
|
v-icon(v-text='mdiArrowRight')
|
||||||
|
|
||||||
@@ -83,10 +83,6 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['settings']),
|
...mapState(['settings']),
|
||||||
showSMTPAlert () {
|
|
||||||
return !this.setup &&
|
|
||||||
(!this.settings.admin_email || !this.settings.smtp || (!this.settings.smtp.sendmail && !this.settings.smtp.host))
|
|
||||||
},
|
|
||||||
instance_locale: {
|
instance_locale: {
|
||||||
get () { return this.settings.instance_locale },
|
get () { return this.settings.instance_locale },
|
||||||
set (value) { this.setSetting({ key: 'instance_locale', value }) }
|
set (value) { this.setSetting({ key: 'instance_locale', value }) }
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export default {
|
|||||||
const user = await this.$axios.$post('/user/register', this.user)
|
const user = await this.$axios.$post('/user/register', this.user)
|
||||||
// this is the first user registered
|
// this is the first user registered
|
||||||
const first_user = user && user.is_admin && user.is_active
|
const first_user = user && user.is_admin && user.is_active
|
||||||
this.$root.$message(first_user ? 'register.first_user': 'register.complete')
|
this.$root.$message(first_user ? 'register.first_user': 'register.complete', { color: 'success' })
|
||||||
this.$router.replace('/')
|
this.$router.replace('/')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const error = get(e, 'response.data.errors[0].message', String(e))
|
const error = get(e, 'response.data.errors[0].message', String(e))
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const Auth = {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
isAuth (req, res, next) {
|
isAuth (_req, res, next) {
|
||||||
if (res.locals.user) {
|
if (res.locals.user) {
|
||||||
next()
|
next()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -171,6 +171,10 @@ const settingsController = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getSMTPSettings (_req, res) {
|
||||||
|
return res.json(settingsController['settings']['smtp'])
|
||||||
|
},
|
||||||
|
|
||||||
setLogo (req, res) {
|
setLogo (req, res) {
|
||||||
if (!req.file) {
|
if (!req.file) {
|
||||||
settingsController.set('logo', false)
|
settingsController.set('logo', false)
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ if (config.status !== 'READY') {
|
|||||||
api.post('/settings', isAdmin, settingsController.setRequest)
|
api.post('/settings', isAdmin, settingsController.setRequest)
|
||||||
api.post('/settings/logo', isAdmin, multer({ dest: config.upload_path }).single('logo'), settingsController.setLogo)
|
api.post('/settings/logo', isAdmin, multer({ dest: config.upload_path }).single('logo'), settingsController.setLogo)
|
||||||
api.post('/settings/smtp', isAdmin, settingsController.testSMTP)
|
api.post('/settings/smtp', isAdmin, settingsController.testSMTP)
|
||||||
|
api.get('/settings/smtp', isAdmin, settingsController.getSMTPSettings)
|
||||||
|
|
||||||
// get unconfirmed events
|
// get unconfirmed events
|
||||||
api.get('/event/unconfirmed', isAdmin, eventController.getUnconfirmed)
|
api.get('/event/unconfirmed', isAdmin, eventController.getUnconfirmed)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const oauthServer = new OAuthServer({
|
|||||||
debug: true,
|
debug: true,
|
||||||
requireClientAuthentication: { password: false },
|
requireClientAuthentication: { password: false },
|
||||||
authenticateHandler: {
|
authenticateHandler: {
|
||||||
handle (req, res) {
|
handle (_req, res) {
|
||||||
if (!res.locals.user) {
|
if (!res.locals.user) {
|
||||||
throw new Error('Not authenticated!')
|
throw new Error('Not authenticated!')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,24 +69,16 @@ module.exports = {
|
|||||||
next()
|
next()
|
||||||
},
|
},
|
||||||
|
|
||||||
async initSettings (req, res, next) {
|
async initSettings (_req, res, next) {
|
||||||
// initialize settings
|
// initialize settings
|
||||||
res.locals.settings = cloneDeep(settingsController.settings)
|
res.locals.settings = cloneDeep(settingsController.settings)
|
||||||
|
delete res.locals.settings.smtp
|
||||||
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.publicKey
|
delete res.locals.settings.publicKey
|
||||||
res.locals.settings.baseurl = config.baseurl
|
res.locals.settings.baseurl = config.baseurl
|
||||||
res.locals.settings.hostname = config.hostname
|
res.locals.settings.hostname = config.hostname
|
||||||
res.locals.settings.title = res.locals.settings.title || config.title
|
res.locals.settings.title = res.locals.settings.title || config.title
|
||||||
res.locals.settings.description = res.locals.settings.description || config.description
|
res.locals.settings.description = res.locals.settings.description || config.description
|
||||||
res.locals.settings.version = pkg.version
|
res.locals.settings.version = pkg.version
|
||||||
|
|
||||||
// set user locale
|
// set user locale
|
||||||
res.locals.user_locale = settingsController.user_locale[res.locals.acceptedLocale]
|
res.locals.user_locale = settingsController.user_locale[res.locals.acceptedLocale]
|
||||||
next()
|
next()
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ app.use((error, _req, res, _next) => {
|
|||||||
// remaining request goes to nuxt
|
// remaining request goes to nuxt
|
||||||
// first nuxt component is ./pages/index.vue (with ./layouts/default.vue)
|
// first nuxt component is ./pages/index.vue (with ./layouts/default.vue)
|
||||||
// prefill current events, tags, places and announcements (used in every path)
|
// 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') {
|
if (config.status === 'READY') {
|
||||||
|
|
||||||
const announceController = require('./api/controller/announce')
|
const announceController = require('./api/controller/announce')
|
||||||
@@ -86,14 +86,5 @@ app.use(async (req, res, next) => {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
handler: app,
|
handler: app,
|
||||||
load () {
|
|
||||||
console.error('dentro load !')
|
|
||||||
},
|
|
||||||
unload: () => initialize.shutdown(false)
|
unload: () => initialize.shutdown(false)
|
||||||
// async unload () {
|
|
||||||
// const db = require('./api/models/index')
|
|
||||||
// await db.close()
|
|
||||||
// process.off('SIGTERM')
|
|
||||||
// process.off('SIGINT')
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user