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
ed0253cd
Commit
ed0253cd
authored
Apr 29, 2017
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: Fixed socket.io guest authorization + rights
parent
5c9fe147
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
10 deletions
+14
-10
ws.js
server/controllers/ws.js
+7
-1
index.js
server/index.js
+4
-5
entries.js
server/libs/entries.js
+0
-1
error-forbidden.pug
server/views/error-forbidden.pug
+1
-1
error-notexist.pug
server/views/error-notexist.pug
+1
-1
error.pug
server/views/error.pug
+1
-1
No files found.
server/controllers/ws.js
View file @
ed0253cd
'use strict'
'use strict'
/* global appconfig, rights */
/* eslint-disable standard/no-callback-literal */
/* eslint-disable standard/no-callback-literal */
const
_
=
require
(
'lodash'
)
const
_
=
require
(
'lodash'
)
module
.
exports
=
(
socket
)
=>
{
module
.
exports
=
(
socket
)
=>
{
// Check if Guest
if
(
!
socket
.
request
.
user
.
logged_in
)
{
socket
.
request
.
user
=
_
.
assign
(
rights
.
guest
,
socket
.
request
.
user
)
}
// -----------------------------------------
// -----------------------------------------
// SEARCH
// SEARCH
// -----------------------------------------
// -----------------------------------------
...
@@ -22,7 +28,7 @@ module.exports = (socket) => {
...
@@ -22,7 +28,7 @@ module.exports = (socket) => {
// TREE VIEW (LIST ALL PAGES)
// TREE VIEW (LIST ALL PAGES)
// -----------------------------------------
// -----------------------------------------
if
(
socket
.
request
.
user
.
logged_in
)
{
if
(
appconfig
.
public
||
socket
.
request
.
user
.
logged_in
)
{
socket
.
on
(
'treeFetch'
,
(
data
,
cb
)
=>
{
socket
.
on
(
'treeFetch'
,
(
data
,
cb
)
=>
{
cb
=
cb
||
_
.
noop
cb
=
cb
||
_
.
noop
entries
.
getFromTree
(
data
.
basePath
,
socket
.
request
.
user
).
then
((
f
)
=>
{
entries
.
getFromTree
(
data
.
basePath
,
socket
.
request
.
user
).
then
((
f
)
=>
{
...
...
server/index.js
View file @
ed0253cd
...
@@ -92,14 +92,14 @@ require('./libs/auth')(passport)
...
@@ -92,14 +92,14 @@ require('./libs/auth')(passport)
global
.
rights
=
require
(
'./libs/rights'
)
global
.
rights
=
require
(
'./libs/rights'
)
rights
.
init
()
rights
.
init
()
var
sessionStore
=
new
SessionMongoStore
({
let
sessionStore
=
new
SessionMongoStore
({
mongooseConnection
:
db
.
connection
,
mongooseConnection
:
db
.
connection
,
touchAfter
:
15
touchAfter
:
15
})
})
app
.
use
(
cookieParser
())
app
.
use
(
cookieParser
())
app
.
use
(
session
({
app
.
use
(
session
({
name
:
'
requarkswiki
.sid'
,
name
:
'
wikijs
.sid'
,
store
:
sessionStore
,
store
:
sessionStore
,
secret
:
appconfig
.
sessionSecret
,
secret
:
appconfig
.
sessionSecret
,
resave
:
false
,
resave
:
false
,
...
@@ -221,16 +221,15 @@ server.on('listening', () => {
...
@@ -221,16 +221,15 @@ server.on('listening', () => {
// ----------------------------------------
// ----------------------------------------
io
.
use
(
passportSocketIo
.
authorize
({
io
.
use
(
passportSocketIo
.
authorize
({
key
:
'
requarkswiki
.sid'
,
key
:
'
wikijs
.sid'
,
store
:
sessionStore
,
store
:
sessionStore
,
secret
:
appconfig
.
sessionSecret
,
secret
:
appconfig
.
sessionSecret
,
passport
,
cookieParser
,
cookieParser
,
success
:
(
data
,
accept
)
=>
{
success
:
(
data
,
accept
)
=>
{
accept
()
accept
()
},
},
fail
:
(
data
,
message
,
error
,
accept
)
=>
{
fail
:
(
data
,
message
,
error
,
accept
)
=>
{
return
accept
(
new
Error
(
message
)
)
accept
(
)
}
}
}))
}))
...
...
server/libs/entries.js
View file @
ed0253cd
...
@@ -399,7 +399,6 @@ module.exports = {
...
@@ -399,7 +399,6 @@ module.exports = {
getFromTree
(
basePath
,
usr
)
{
getFromTree
(
basePath
,
usr
)
{
return
db
.
Entry
.
find
({
parentPath
:
basePath
},
'title parentPath isDirectory isEntry'
).
sort
({
title
:
'asc'
}).
then
(
results
=>
{
return
db
.
Entry
.
find
({
parentPath
:
basePath
},
'title parentPath isDirectory isEntry'
).
sort
({
title
:
'asc'
}).
then
(
results
=>
{
return
_
.
filter
(
results
,
r
=>
{
return
_
.
filter
(
results
,
r
=>
{
console
.
log
(
r
.
_id
,
rights
.
checkRole
(
r
.
_id
,
usr
.
rights
,
'read'
))
return
rights
.
checkRole
(
'/'
+
r
.
_id
,
usr
.
rights
,
'read'
)
return
rights
.
checkRole
(
'/'
+
r
.
_id
,
usr
.
rights
,
'read'
)
})
})
})
})
...
...
server/views/error-forbidden.pug
View file @
ed0253cd
...
@@ -22,7 +22,7 @@ html(data-logic='error')
...
@@ -22,7 +22,7 @@ html(data-logic='error')
body(class='is-forbidden')
body(class='is-forbidden')
.container
.container
a(href='/'): img(src='/
favicons/android-icon-96x96
.png')
a(href='/'): img(src='/
images/logo
.png')
h1 Forbidden
h1 Forbidden
h2 Sorry, you don't have the necessary permissions to access this page.
h2 Sorry, you don't have the necessary permissions to access this page.
a.button.is-amber.is-inverted(href='/') Go Home
a.button.is-amber.is-inverted(href='/') Go Home
...
...
server/views/error-notexist.pug
View file @
ed0253cd
...
@@ -22,7 +22,7 @@ html(data-logic='error')
...
@@ -22,7 +22,7 @@ html(data-logic='error')
body(class='is-notexist')
body(class='is-notexist')
.container
.container
a(href='/'): img(src='/
favicons/android-icon-96x96
.png')
a(href='/'): img(src='/
images/logo
.png')
h1= message
h1= message
h2 Would you like to create this entry?
h2 Would you like to create this entry?
a.button.is-amber.is-inverted.is-featured(href='/create/' + newpath) Create
a.button.is-amber.is-inverted.is-featured(href='/create/' + newpath) Create
...
...
server/views/error.pug
View file @
ed0253cd
...
@@ -22,7 +22,7 @@ html(data-logic='error')
...
@@ -22,7 +22,7 @@ html(data-logic='error')
body(class='is-error')
body(class='is-error')
.container
.container
a(href='/'): img(src='/
favicons/android-icon-96x96
.png')
a(href='/'): img(src='/
images/logo
.png')
h1= message
h1= message
h2 Oops, something went wrong
h2 Oops, something went wrong
a.button.is-amber.is-inverted.is-featured(href='/') Go Home
a.button.is-amber.is-inverted.is-featured(href='/') 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