feat: Admin + Uploads ctrl localization

pull/95/head
NGPixel 8 years ago
parent 3db9cf4efd
commit ea2d98c9b6

@ -167,11 +167,11 @@ router.post('/users/create', (req, res) => {
router.post('/users/:id', (req, res) => {
if (!res.locals.rights.manage) {
return res.status(401).json({ msg: 'Unauthorized' })
return res.status(401).json({ msg: lang.t('errors:unauthorized') })
}
if (!validator.isMongoId(req.params.id)) {
return res.status(400).json({ msg: 'Invalid User ID' })
return res.status(400).json({ msg: lang.t('errors:invaliduserid') })
}
return db.User.findById(req.params.id).then((usr) => {
@ -180,7 +180,7 @@ router.post('/users/:id', (req, res) => {
if (usr.provider === 'local' && req.body.password !== '********') {
let nPwd = _.trim(req.body.password)
if (nPwd.length < 6) {
return Promise.reject(new Error('New Password too short!'))
return Promise.reject(new Error(lang.t('errors:newpasswordtooshort')))
} else {
return db.User.hashPassword(nPwd).then((pwd) => {
usr.password = pwd
@ -208,11 +208,11 @@ router.post('/users/:id', (req, res) => {
*/
router.delete('/users/:id', (req, res) => {
if (!res.locals.rights.manage) {
return res.status(401).json({ msg: 'Unauthorized' })
return res.status(401).json({ msg: lang.t('errors:unauthorized') })
}
if (!validator.isMongoId(req.params.id)) {
return res.status(400).json({ msg: 'Invalid User ID' })
return res.status(400).json({ msg: lang.t('errors:invaliduserid') })
}
return db.User.findByIdAndRemove(req.params.id).then(() => {

@ -40,7 +40,7 @@ router.post('/img', lcdata.uploadImgHandler, (req, res, next) => {
upl.validateUploadsFolder(destFolder).then((destFolderPath) => {
if (!destFolderPath) {
res.json({ ok: false, msg: 'Invalid Folder' })
res.json({ ok: false, msg: lang.t('errors:invalidfolder') })
return true
}
@ -58,7 +58,7 @@ router.post('/img', lcdata.uploadImgHandler, (req, res, next) => {
let mimeInfo = fileType(buf)
if (!_.includes(['image/png', 'image/jpeg', 'image/gif', 'image/webp'], mimeInfo.mime)) {
return Promise.reject(new Error('Invalid file type.'))
return Promise.reject(new Error(lang.t('errors:invalidfiletype')))
}
return true
}).then(() => {
@ -97,7 +97,7 @@ router.post('/file', lcdata.uploadFileHandler, (req, res, next) => {
upl.validateUploadsFolder(destFolder).then((destFolderPath) => {
if (!destFolderPath) {
res.json({ ok: false, msg: 'Invalid Folder' })
res.json({ ok: false, msg: lang.t('errors:invalidfolder') })
return true
}

@ -1,16 +1,19 @@
{
"generic": "Oops, something went wrong",
"notexistdetail": "Would you like to create this entry?",
"alreadyexists": "This entry already exists!",
"debugmsg": "Detailed debug trail",
"forbidden": "Forbidden",
"forbiddendetail": "Sorry, you don't have the necessary permissions to access this page.",
"unauthorized": "Unauthorized",
"debugmsg": "Detailed debug trail",
"generic": "Oops, something went wrong",
"invalidaction": "Invalid Action.",
"invalidfiletype": "Invalid File Type.",
"invalidfolder": "Invalid Folder.",
"invalidpath": "Invalid page path.",
"invaliduserid": "Invalid User Id",
"newpasswordtooshort": "New password is too short!",
"notexistdetail": "Would you like to create this entry?",
"reservedname": "You cannot create a document with this name as it is reserved by the system.",
"alreadyexists": "This entry already exists!",
"starterfailed": "Could not load starter content!",
"unauthorized": "Unauthorized",
"actions": {
"create": "Create",
"gohome": "Go Home",

Loading…
Cancel
Save