mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 16:42:22 +01:00
fix SMTP configuration
This commit is contained in:
parent
9e86a9399b
commit
92c676622d
9 changed files with 16 additions and 30 deletions
|
@ -46,7 +46,6 @@ v-card
|
|||
import { mapActions, mapState } from 'vuex'
|
||||
export default {
|
||||
data ({ $store }) {
|
||||
const smtp = { auth: {}, ...$store.state.settings.smtp }
|
||||
// if ($store.state.settings.smtp) {
|
||||
// smtp.host = $store.state.settings.smtp.host
|
||||
// if ($store.state.settings.smtp.auth) {
|
||||
|
@ -59,10 +58,13 @@ export default {
|
|||
return {
|
||||
isValid: false,
|
||||
loading: false,
|
||||
smtp,
|
||||
smtp: { auth: {} },
|
||||
admin_email: $store.state.settings.admin_email || ''
|
||||
}
|
||||
},
|
||||
async fetch () {
|
||||
this.smtp = await this.$axios.$get('/settings/smtp')
|
||||
},
|
||||
computed: mapState(['settings']),
|
||||
watch: {
|
||||
'smtp.secure' (value) {
|
||||
|
|
|
@ -53,7 +53,7 @@ v-container
|
|||
|
||||
v-card-actions
|
||||
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-icon(v-text='mdiArrowRight')
|
||||
|
||||
|
@ -83,10 +83,6 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
...mapState(['settings']),
|
||||
showSMTPAlert () {
|
||||
return !this.setup &&
|
||||
(!this.settings.admin_email || !this.settings.smtp || (!this.settings.smtp.sendmail && !this.settings.smtp.host))
|
||||
},
|
||||
instance_locale: {
|
||||
get () { return this.settings.instance_locale },
|
||||
set (value) { this.setSetting({ key: 'instance_locale', value }) }
|
||||
|
|
|
@ -66,7 +66,7 @@ export default {
|
|||
const user = await this.$axios.$post('/user/register', this.user)
|
||||
// this is the first user registered
|
||||
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('/')
|
||||
} catch (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) {
|
||||
next()
|
||||
} else {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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!')
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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')
|
||||
// }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue