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
9578989b
Commit
9578989b
authored
Jan 02, 2017
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added access check for write and manage actions
parent
4625a302
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
94 additions
and
33 deletions
+94
-33
README.md
README.md
+2
-2
admin.js
controllers/admin.js
+25
-0
pages.js
controllers/pages.js
+30
-1
server.js
server.js
+1
-0
_layout.pug
views/pages/admin/_layout.pug
+9
-8
source.pug
views/pages/source.pug
+11
-9
view.pug
views/pages/view.pug
+16
-13
No files found.
README.md
View file @
9578989b
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
-
[
x
]
Facebook
-
[
x
]
Facebook
-
[
x
]
Access Rights
-
[
x
]
Access Rights
-
[
x
]
View
-
[
x
]
View
-
[
]
Edit / Create
-
[
x
]
Edit / Create
-
[
x
]
Background Agent (git sync, cache purge, etc.)
-
[
x
]
Background Agent (git sync, cache purge, etc.)
-
[
x
]
Caching
-
[
x
]
Caching
-
[
x
]
Create Entry
-
[
x
]
Create Entry
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
-
[
x
]
Prerequisites
-
[
x
]
Prerequisites
-
[
x
]
Install
-
[
x
]
Install
-
[
]
Authentication
-
[
]
Authentication
-
[
]
Git
-
[
x
]
Git
-
[
x
]
Upgrade
-
[
x
]
Upgrade
-
[
x
]
Edit Entry
-
[
x
]
Edit Entry
-
[
x
]
Git Management
-
[
x
]
Git Management
...
...
controllers/admin.js
View file @
9578989b
...
@@ -12,10 +12,21 @@ router.get('/', (req, res) => {
...
@@ -12,10 +12,21 @@ router.get('/', (req, res) => {
});
});
router
.
get
(
'/profile'
,
(
req
,
res
)
=>
{
router
.
get
(
'/profile'
,
(
req
,
res
)
=>
{
if
(
res
.
locals
.
isGuest
)
{
return
res
.
render
(
'error-forbidden'
);
}
res
.
render
(
'pages/admin/profile'
,
{
adminTab
:
'profile'
});
res
.
render
(
'pages/admin/profile'
,
{
adminTab
:
'profile'
});
});
});
router
.
get
(
'/stats'
,
(
req
,
res
)
=>
{
router
.
get
(
'/stats'
,
(
req
,
res
)
=>
{
if
(
res
.
locals
.
isGuest
)
{
return
res
.
render
(
'error-forbidden'
);
}
Promise
.
all
([
Promise
.
all
([
db
.
Entry
.
count
(),
db
.
Entry
.
count
(),
db
.
UplFile
.
count
(),
db
.
UplFile
.
count
(),
...
@@ -28,14 +39,27 @@ router.get('/stats', (req, res) => {
...
@@ -28,14 +39,27 @@ router.get('/stats', (req, res) => {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
throw
err
;
throw
err
;
});
});
});
});
router
.
get
(
'/users'
,
(
req
,
res
)
=>
{
router
.
get
(
'/users'
,
(
req
,
res
)
=>
{
if
(
!
res
.
locals
.
rights
.
manage
)
{
return
res
.
render
(
'error-forbidden'
);
}
res
.
render
(
'pages/admin/users'
,
{
adminTab
:
'users'
});
res
.
render
(
'pages/admin/users'
,
{
adminTab
:
'users'
});
});
});
router
.
get
(
'/settings'
,
(
req
,
res
)
=>
{
router
.
get
(
'/settings'
,
(
req
,
res
)
=>
{
if
(
!
res
.
locals
.
rights
.
manage
)
{
return
res
.
render
(
'error-forbidden'
);
}
res
.
render
(
'pages/admin/settings'
,
{
adminTab
:
'settings'
});
res
.
render
(
'pages/admin/settings'
,
{
adminTab
:
'settings'
});
});
});
module
.
exports
=
router
;
module
.
exports
=
router
;
\ No newline at end of file
controllers/pages.js
View file @
9578989b
...
@@ -13,6 +13,10 @@ var _ = require('lodash');
...
@@ -13,6 +13,10 @@ var _ = require('lodash');
*/
*/
router
.
get
(
'/edit/*'
,
(
req
,
res
,
next
)
=>
{
router
.
get
(
'/edit/*'
,
(
req
,
res
,
next
)
=>
{
if
(
!
res
.
locals
.
rights
.
write
)
{
return
res
.
render
(
'error-forbidden'
);
}
let
safePath
=
entries
.
parsePath
(
_
.
replace
(
req
.
path
,
'/edit'
,
''
));
let
safePath
=
entries
.
parsePath
(
_
.
replace
(
req
.
path
,
'/edit'
,
''
));
entries
.
fetchOriginal
(
safePath
,
{
entries
.
fetchOriginal
(
safePath
,
{
...
@@ -40,6 +44,13 @@ router.get('/edit/*', (req, res, next) => {
...
@@ -40,6 +44,13 @@ router.get('/edit/*', (req, res, next) => {
router
.
put
(
'/edit/*'
,
(
req
,
res
,
next
)
=>
{
router
.
put
(
'/edit/*'
,
(
req
,
res
,
next
)
=>
{
if
(
!
res
.
locals
.
rights
.
write
)
{
return
res
.
json
({
ok
:
false
,
error
:
'Forbidden'
});
}
let
safePath
=
entries
.
parsePath
(
_
.
replace
(
req
.
path
,
'/edit'
,
''
));
let
safePath
=
entries
.
parsePath
(
_
.
replace
(
req
.
path
,
'/edit'
,
''
));
entries
.
update
(
safePath
,
req
.
body
.
markdown
).
then
(()
=>
{
entries
.
update
(
safePath
,
req
.
body
.
markdown
).
then
(()
=>
{
...
@@ -61,6 +72,10 @@ router.put('/edit/*', (req, res, next) => {
...
@@ -61,6 +72,10 @@ router.put('/edit/*', (req, res, next) => {
router
.
get
(
'/create/*'
,
(
req
,
res
,
next
)
=>
{
router
.
get
(
'/create/*'
,
(
req
,
res
,
next
)
=>
{
if
(
!
res
.
locals
.
rights
.
write
)
{
return
res
.
render
(
'error-forbidden'
);
}
if
(
_
.
some
([
'create'
,
'edit'
,
'account'
,
'source'
,
'history'
,
'mk'
],
(
e
)
=>
{
return
_
.
startsWith
(
req
.
path
,
'/create/'
+
e
);
}))
{
if
(
_
.
some
([
'create'
,
'edit'
,
'account'
,
'source'
,
'history'
,
'mk'
],
(
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
:
'You cannot create a document with this name as it is reserved by the system.'
,
...
@@ -102,6 +117,13 @@ router.get('/create/*', (req, res, next) => {
...
@@ -102,6 +117,13 @@ router.get('/create/*', (req, res, next) => {
router
.
put
(
'/create/*'
,
(
req
,
res
,
next
)
=>
{
router
.
put
(
'/create/*'
,
(
req
,
res
,
next
)
=>
{
if
(
!
res
.
locals
.
rights
.
write
)
{
return
res
.
json
({
ok
:
false
,
error
:
'Forbidden'
});
}
let
safePath
=
entries
.
parsePath
(
_
.
replace
(
req
.
path
,
'/create'
,
''
));
let
safePath
=
entries
.
parsePath
(
_
.
replace
(
req
.
path
,
'/create'
,
''
));
entries
.
create
(
safePath
,
req
.
body
.
markdown
).
then
(()
=>
{
entries
.
create
(
safePath
,
req
.
body
.
markdown
).
then
(()
=>
{
...
@@ -109,7 +131,7 @@ router.put('/create/*', (req, res, next) => {
...
@@ -109,7 +131,7 @@ router.put('/create/*', (req, res, next) => {
ok
:
true
ok
:
true
})
||
true
;
})
||
true
;
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
res
.
json
({
re
turn
re
s
.
json
({
ok
:
false
,
ok
:
false
,
error
:
err
.
message
error
:
err
.
message
});
});
...
@@ -192,6 +214,13 @@ router.get('/*', (req, res, next) => {
...
@@ -192,6 +214,13 @@ router.get('/*', (req, res, next) => {
*/
*/
router
.
put
(
'/*'
,
(
req
,
res
,
next
)
=>
{
router
.
put
(
'/*'
,
(
req
,
res
,
next
)
=>
{
if
(
!
res
.
locals
.
rights
.
write
)
{
return
res
.
json
({
ok
:
false
,
error
:
'Forbidden'
});
}
let
safePath
=
entries
.
parsePath
(
req
.
path
);
let
safePath
=
entries
.
parsePath
(
req
.
path
);
if
(
_
.
isEmpty
(
req
.
body
.
move
))
{
if
(
_
.
isEmpty
(
req
.
body
.
move
))
{
...
...
server.js
View file @
9578989b
...
@@ -89,6 +89,7 @@ app.use(express.static(path.join(ROOTPATH, 'assets')));
...
@@ -89,6 +89,7 @@ app.use(express.static(path.join(ROOTPATH, 'assets')));
var
strategy
=
require
(
CORE_PATH
+
'core-libs/auth'
)(
passport
,
appconfig
);
var
strategy
=
require
(
CORE_PATH
+
'core-libs/auth'
)(
passport
,
appconfig
);
global
.
rights
=
require
(
CORE_PATH
+
'core-libs/rights'
);
global
.
rights
=
require
(
CORE_PATH
+
'core-libs/rights'
);
rights
.
init
();
var
sessionStore
=
new
sessionMongoStore
({
var
sessionStore
=
new
sessionMongoStore
({
mongooseConnection
:
db
.
connection
,
mongooseConnection
:
db
.
connection
,
...
...
views/pages/admin/_layout.pug
View file @
9578989b
...
@@ -41,14 +41,15 @@ block content
...
@@ -41,14 +41,15 @@ block content
a(href='/admin/stats')
a(href='/admin/stats')
i.icon-bar-graph-2
i.icon-bar-graph-2
span Stats
span Stats
li
if rights.manage
a(href='/admin/users')
li
i.icon-users
a(href='/admin/users')
span Users
i.icon-users
li
span Users
a(href='/admin/settings')
li
i.icon-cog
a(href='/admin/settings')
span Site Settings
i.icon-cog
span Site Settings
li
li
a(href='/logout')
a(href='/logout')
i.icon-delete2
i.icon-delete2
...
...
views/pages/source.pug
View file @
9578989b
...
@@ -6,18 +6,20 @@ block rootNavCenter
...
@@ -6,18 +6,20 @@ block rootNavCenter
block rootNavRight
block rootNavRight
i.nav-item#notifload
i.nav-item#notifload
span.nav-item
span.nav-item
a.button.is-outlined.btn-move-prompt.is-hidden
if rights.write
i.icon-shuffle
a.button.is-outlined.btn-move-prompt.is-hidden
span Move
i.icon-shuffle
span Move
a.button.is-outlined(href='/' + pageData.meta.path)
a.button.is-outlined(href='/' + pageData.meta.path)
i.icon-loader
i.icon-loader
span Normal View
span Normal View
a.button.is-orange(href='/edit/' + pageData.meta.path)
if rights.write
i.fa.fa-edit
a.button.is-orange(href='/edit/' + pageData.meta.path)
span Edit
i.fa.fa-edit
a.button.is-blue.btn-create-prompt
span Edit
i.fa.fa-plus
a.button.is-blue.btn-create-prompt
span Create
i.fa.fa-plus
span Create
block content
block content
...
...
views/pages/view.pug
View file @
9578989b
...
@@ -11,18 +11,20 @@ mixin tocMenu(ti)
...
@@ -11,18 +11,20 @@ mixin tocMenu(ti)
block rootNavRight
block rootNavRight
i.nav-item#notifload
i.nav-item#notifload
.nav-item
.nav-item
a.button.is-outlined.btn-move-prompt.is-hidden
if rights.write
i.icon-shuffle
a.button.is-outlined.btn-move-prompt.is-hidden
span Move
i.icon-shuffle
span Move
a.button.is-outlined(href='/source/' + pageData.meta.path)
a.button.is-outlined(href='/source/' + pageData.meta.path)
i.icon-loader
i.icon-loader
span Source
span Source
a.button(href='/edit/' + pageData.meta.path)
if rights.write
i.icon-document-text
a.button(href='/edit/' + pageData.meta.path)
span Edit
i.icon-document-text
a.button.btn-create-prompt
span Edit
i.icon-plus
a.button.btn-create-prompt
span Create
i.icon-plus
span Create
block content
block content
...
@@ -46,10 +48,11 @@ block content
...
@@ -46,10 +48,11 @@ block content
a(href='/' + pageData.parent.path)
a(href='/' + pageData.parent.path)
i.icon-reply
i.icon-reply
span= pageData.parent.title
span= pageData.parent.title
li
if !isGuest
a(href='/admin')
li
i.icon-head
a(href='/admin')
span Account
i.icon-head
span Account
aside.stickyscroll(data-margin-top=40)
aside.stickyscroll(data-margin-top=40)
.sidebar-label
.sidebar-label
i.icon-th-list
i.icon-th-list
...
...
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