|
|
@ -31,7 +31,7 @@ router.get('/edit/*', (req, res, next) => {
|
|
|
|
if (pageData) {
|
|
|
|
if (pageData) {
|
|
|
|
res.render('pages/edit', { pageData })
|
|
|
|
res.render('pages/edit', { pageData })
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new Error('Invalid page path.')
|
|
|
|
throw new Error(lang.t('errors:invalidpath'))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}).catch((err) => {
|
|
|
|
}).catch((err) => {
|
|
|
@ -46,7 +46,7 @@ router.put('/edit/*', (req, res, next) => {
|
|
|
|
if (!res.locals.rights.write) {
|
|
|
|
if (!res.locals.rights.write) {
|
|
|
|
return res.json({
|
|
|
|
return res.json({
|
|
|
|
ok: false,
|
|
|
|
ok: false,
|
|
|
|
error: 'Forbidden'
|
|
|
|
error: lang.t('errors:forbidden')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -75,7 +75,7 @@ router.get('/create/*', (req, res, next) => {
|
|
|
|
|
|
|
|
|
|
|
|
if (_.some(['create', 'edit', 'account', 'source', 'history', 'mk', 'all'], (e) => { return _.startsWith(req.path, '/create/' + e) })) {
|
|
|
|
if (_.some(['create', 'edit', 'account', 'source', 'history', 'mk', 'all'], (e) => { return _.startsWith(req.path, '/create/' + e) })) {
|
|
|
|
return res.render('error', {
|
|
|
|
return res.render('error', {
|
|
|
|
message: 'You cannot create a document with this name as it is reserved by the system.',
|
|
|
|
message: lang.t('errors:reservedname'),
|
|
|
|
error: {}
|
|
|
|
error: {}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -97,10 +97,10 @@ router.get('/create/*', (req, res, next) => {
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}).catch((err) => {
|
|
|
|
}).catch((err) => {
|
|
|
|
winston.warn(err)
|
|
|
|
winston.warn(err)
|
|
|
|
throw new Error('Could not load starter content!')
|
|
|
|
throw new Error(lang.t('errors:starterfailed'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new Error('This entry already exists!')
|
|
|
|
throw new Error(lang.t('errors:alreadyexists'))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).catch((err) => {
|
|
|
|
}).catch((err) => {
|
|
|
|
res.render('error', {
|
|
|
|
res.render('error', {
|
|
|
@ -114,7 +114,7 @@ router.put('/create/*', (req, res, next) => {
|
|
|
|
if (!res.locals.rights.write) {
|
|
|
|
if (!res.locals.rights.write) {
|
|
|
|
return res.json({
|
|
|
|
return res.json({
|
|
|
|
ok: false,
|
|
|
|
ok: false,
|
|
|
|
error: 'Forbidden'
|
|
|
|
error: lang.t('errors:forbidden')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -168,7 +168,7 @@ router.get('/source/*', (req, res, next) => {
|
|
|
|
if (pageData) {
|
|
|
|
if (pageData) {
|
|
|
|
res.render('pages/source', { pageData })
|
|
|
|
res.render('pages/source', { pageData })
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new Error('Invalid page path.')
|
|
|
|
throw new Error(lang.t('errors:invalidpath'))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}).catch((err) => {
|
|
|
|
}).catch((err) => {
|
|
|
@ -189,7 +189,7 @@ router.get('/hist/*', (req, res, next) => {
|
|
|
|
if (pageData) {
|
|
|
|
if (pageData) {
|
|
|
|
res.render('pages/history', { pageData })
|
|
|
|
res.render('pages/history', { pageData })
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new Error('Invalid page path.')
|
|
|
|
throw new Error(lang.t('errors:invalidpath'))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}).catch((err) => {
|
|
|
|
}).catch((err) => {
|
|
|
@ -240,7 +240,7 @@ router.put('/*', (req, res, next) => {
|
|
|
|
if (!res.locals.rights.write) {
|
|
|
|
if (!res.locals.rights.write) {
|
|
|
|
return res.json({
|
|
|
|
return res.json({
|
|
|
|
ok: false,
|
|
|
|
ok: false,
|
|
|
|
error: 'Forbidden'
|
|
|
|
error: lang.t('errors:forbidden')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -249,7 +249,7 @@ router.put('/*', (req, res, next) => {
|
|
|
|
if (_.isEmpty(req.body.move)) {
|
|
|
|
if (_.isEmpty(req.body.move)) {
|
|
|
|
return res.json({
|
|
|
|
return res.json({
|
|
|
|
ok: false,
|
|
|
|
ok: false,
|
|
|
|
error: 'Invalid document action call.'
|
|
|
|
error: lang.t('errors:invalidaction')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|