feat: Admin + Uploads ctrl localization
This commit is contained in:
parent
3db9cf4efd
commit
ea2d98c9b6
@ -167,11 +167,11 @@ router.post('/users/create', (req, res) => {
|
|||||||
|
|
||||||
router.post('/users/:id', (req, res) => {
|
router.post('/users/:id', (req, res) => {
|
||||||
if (!res.locals.rights.manage) {
|
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)) {
|
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) => {
|
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 !== '********') {
|
if (usr.provider === 'local' && req.body.password !== '********') {
|
||||||
let nPwd = _.trim(req.body.password)
|
let nPwd = _.trim(req.body.password)
|
||||||
if (nPwd.length < 6) {
|
if (nPwd.length < 6) {
|
||||||
return Promise.reject(new Error('New Password too short!'))
|
return Promise.reject(new Error(lang.t('errors:newpasswordtooshort')))
|
||||||
} else {
|
} else {
|
||||||
return db.User.hashPassword(nPwd).then((pwd) => {
|
return db.User.hashPassword(nPwd).then((pwd) => {
|
||||||
usr.password = pwd
|
usr.password = pwd
|
||||||
@ -208,11 +208,11 @@ router.post('/users/:id', (req, res) => {
|
|||||||
*/
|
*/
|
||||||
router.delete('/users/:id', (req, res) => {
|
router.delete('/users/:id', (req, res) => {
|
||||||
if (!res.locals.rights.manage) {
|
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)) {
|
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(() => {
|
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) => {
|
upl.validateUploadsFolder(destFolder).then((destFolderPath) => {
|
||||||
if (!destFolderPath) {
|
if (!destFolderPath) {
|
||||||
res.json({ ok: false, msg: 'Invalid Folder' })
|
res.json({ ok: false, msg: lang.t('errors:invalidfolder') })
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ router.post('/img', lcdata.uploadImgHandler, (req, res, next) => {
|
|||||||
|
|
||||||
let mimeInfo = fileType(buf)
|
let mimeInfo = fileType(buf)
|
||||||
if (!_.includes(['image/png', 'image/jpeg', 'image/gif', 'image/webp'], mimeInfo.mime)) {
|
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
|
return true
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
@ -97,7 +97,7 @@ router.post('/file', lcdata.uploadFileHandler, (req, res, next) => {
|
|||||||
|
|
||||||
upl.validateUploadsFolder(destFolder).then((destFolderPath) => {
|
upl.validateUploadsFolder(destFolder).then((destFolderPath) => {
|
||||||
if (!destFolderPath) {
|
if (!destFolderPath) {
|
||||||
res.json({ ok: false, msg: 'Invalid Folder' })
|
res.json({ ok: false, msg: lang.t('errors:invalidfolder') })
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
{
|
{
|
||||||
"generic": "Oops, something went wrong",
|
"alreadyexists": "This entry already exists!",
|
||||||
"notexistdetail": "Would you like to create this entry?",
|
"debugmsg": "Detailed debug trail",
|
||||||
"forbidden": "Forbidden",
|
"forbidden": "Forbidden",
|
||||||
"forbiddendetail": "Sorry, you don't have the necessary permissions to access this page.",
|
"forbiddendetail": "Sorry, you don't have the necessary permissions to access this page.",
|
||||||
"unauthorized": "Unauthorized",
|
"generic": "Oops, something went wrong",
|
||||||
"debugmsg": "Detailed debug trail",
|
|
||||||
"invalidaction": "Invalid Action.",
|
"invalidaction": "Invalid Action.",
|
||||||
|
"invalidfiletype": "Invalid File Type.",
|
||||||
|
"invalidfolder": "Invalid Folder.",
|
||||||
"invalidpath": "Invalid page path.",
|
"invalidpath": "Invalid page path.",
|
||||||
"invaliduserid": "Invalid User Id",
|
"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.",
|
"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!",
|
"starterfailed": "Could not load starter content!",
|
||||||
|
"unauthorized": "Unauthorized",
|
||||||
"actions": {
|
"actions": {
|
||||||
"create": "Create",
|
"create": "Create",
|
||||||
"gohome": "Go Home",
|
"gohome": "Go Home",
|
||||||
|
Loading…
Reference in New Issue
Block a user