Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
ea2d98c9
Commit
ea2d98c9
authored
May 02, 2017
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Admin + Uploads ctrl localization
parent
3db9cf4e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
13 deletions
+16
-13
admin.js
server/controllers/admin.js
+5
-5
uploads.js
server/controllers/uploads.js
+3
-3
errors.json
server/locales/en/errors.json
+8
-5
No files found.
server/controllers/admin.js
View file @
ea2d98c9
...
...
@@ -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
(()
=>
{
...
...
server/controllers/uploads.js
View file @
ea2d98c9
...
...
@@ -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
}
...
...
server/locales/en/errors.json
View file @
ea2d98c9
{
"
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"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment