minors + set Favicon
This commit is contained in:
@@ -100,10 +100,10 @@ const settingsController = {
|
||||
}
|
||||
},
|
||||
|
||||
getUserLocale (req, res) {
|
||||
// load user locale specified in configuration
|
||||
res.json(settingsController.user_locale)
|
||||
},
|
||||
// getUserLocale (req, res) {
|
||||
// // load user locale specified in configuration
|
||||
// res.json(settingsController.user_locale)
|
||||
// },
|
||||
|
||||
async setRequest (req, res) {
|
||||
const { key, value, is_secret } = req.body
|
||||
@@ -111,6 +111,12 @@ const settingsController = {
|
||||
if (ret) { res.sendStatus(200) } else { res.sendStatus(400) }
|
||||
},
|
||||
|
||||
async setFavicon (req, res) {
|
||||
if (!req.file) return res.status(400).send('Mmmmm sould not be here!')
|
||||
await settingsController.set('favicon', path.join(req.file.destination, req.file.filename))
|
||||
res.sendStatus(200)
|
||||
},
|
||||
|
||||
getAllRequest (req, res) {
|
||||
// get public settings and public configuration
|
||||
const settings = {
|
||||
|
||||
@@ -68,10 +68,10 @@ api.delete('/event/notification/:code', eventController.delNotification)
|
||||
|
||||
api.get('/settings', settingsController.getAllRequest)
|
||||
api.post('/settings', isAdmin, settingsController.setRequest)
|
||||
api.post('/settings/favicon', isAdmin, multer({ dest: 'thumb/' }).single('favicon'), settingsController.setFavicon)
|
||||
// api.get('/settings/user_locale', settingsController.getUserLocale)
|
||||
|
||||
api.get('/settings/user_locale', settingsController.getUserLocale)
|
||||
|
||||
// confirm event
|
||||
// confirm eventtags
|
||||
api.get('/event/confirm/:event_id', isAuth, eventController.confirm)
|
||||
api.get('/event/unconfirm/:event_id', isAuth, eventController.unconfirm)
|
||||
|
||||
@@ -83,6 +83,7 @@ api.get('/export/:type', cors, exportController.export)
|
||||
|
||||
// get events in this range
|
||||
api.get('/event/:month/:year', cors, eventController.getAll)
|
||||
api.get('/event', cors, eventController.select)
|
||||
|
||||
api.get('/instances', isAdmin, instanceController.getAll)
|
||||
api.get('/instances/:instance_domain', isAdmin, instanceController.get)
|
||||
|
||||
@@ -30,7 +30,7 @@ module.exports = {
|
||||
const db = require('./api/models')
|
||||
const users = await db.user.findAll()
|
||||
if (users.length) {
|
||||
consola.warn(` ⚠ Non empty db! Please move your current db elsewhere than retry.`)
|
||||
consola.warn(' ⚠ Non empty db! Please move your current db elsewhere than retry.')
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ module.exports = {
|
||||
await db.notification.create({ action: 'Update', type: 'ap', filters: { is_visible: true } })
|
||||
await db.notification.create({ action: 'Delete', type: 'ap', filters: { is_visible: true } })
|
||||
|
||||
// send anon email to administrator
|
||||
// send anon event to administrator
|
||||
await db.notification.create({ action: 'Create', type: 'admin_email', filters: { is_visible: false } })
|
||||
|
||||
// TODO
|
||||
|
||||
@@ -13,7 +13,7 @@ const jwt = expressJwt({
|
||||
if (req.headers.authorization && req.headers.authorization.split(' ')[0] === 'Bearer') {
|
||||
return req.headers.authorization.split(' ')[1]
|
||||
} else if (req.cookies && req.cookies['auth._token.local']) {
|
||||
const [ prefix, token ] = req.cookies['auth._token.local'].split(' ')
|
||||
const [prefix, token] = req.cookies['auth._token.local'].split(' ')
|
||||
if (prefix === 'Bearer') { return token }
|
||||
}
|
||||
return null
|
||||
@@ -28,8 +28,8 @@ module.exports = {
|
||||
req.secretSettings = settingsController.secretSettings
|
||||
|
||||
req.settings.baseurl = config.baseurl
|
||||
req.settings.title = config.title
|
||||
req.settings.description = config.description
|
||||
req.settings.title = req.settings.title || config.title
|
||||
req.settings.description = req.settings.description || config.description
|
||||
req.settings.version = pkg.version
|
||||
|
||||
// set locale and user locale
|
||||
@@ -39,6 +39,7 @@ module.exports = {
|
||||
req.settings.locale = acceptLanguage.get(acceptedLanguages)
|
||||
req.settings.user_locale = settingsController.user_locale[req.settings.locale]
|
||||
moment.locale(req.settings.locale)
|
||||
moment.tz.setDefault(req.settings.instance_timezone)
|
||||
|
||||
// TODO: oauth
|
||||
// auth
|
||||
|
||||
@@ -22,13 +22,16 @@ app.use((req, res, next) => {
|
||||
app.use(spamFilter)
|
||||
|
||||
// serve favicon and static content
|
||||
app.use('/favicon.ico', express.static(path.resolve(config.favicon || './assets/favicon.ico')))
|
||||
app.use('/logo.png', express.static('./static/gancio.png'))
|
||||
app.use('/media/', express.static(config.upload_path))
|
||||
|
||||
// initialize instance settings / authentication / locale
|
||||
app.use(cookieParser())
|
||||
app.use(helpers.initMiddleware)
|
||||
app.use('/favicon.ico', (req, res, next) => {
|
||||
const favicon_path = req.settings.favicon || config.favicon || './assets/favicon.ico'
|
||||
return express.static(path.resolve(favicon_path))(req, res, next)
|
||||
})
|
||||
|
||||
// rss/ics/atom feed
|
||||
app.get('/feed/:type', cors(), exportController.export)
|
||||
|
||||
Reference in New Issue
Block a user