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
a1b6dfb3
Commit
a1b6dfb3
authored
Jun 24, 2017
by
NGPixel
Committed by
Nicolas Giard
Jul 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: Incorrect indentation (eslint)
parent
f37cbac3
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
72 additions
and
80 deletions
+72
-80
settings.json
.vscode/settings.json
+2
-2
auth.js
server/libs/auth.js
+17
-25
db.js
server/libs/db.js
+9
-9
entries.js
server/libs/entries.js
+15
-15
index.js
server/libs/search-index/index.js
+1
-1
search.js
server/libs/search.js
+8
-8
system.js
server/libs/system.js
+18
-18
uploads-agent.js
server/libs/uploads-agent.js
+2
-2
No files found.
.vscode/settings.json
View file @
a1b6dfb3
{
"eslint.enable"
:
true
,
"eslint.autoFixOnSave"
:
fals
e
,
"eslint.autoFixOnSave"
:
tru
e
,
"puglint.enable"
:
true
,
"standard.enable"
:
false
,
"editor.formatOnSave"
:
tru
e
,
"editor.formatOnSave"
:
fals
e
,
"editor.tabSize"
:
2
}
server/libs/auth.js
View file @
a1b6dfb3
...
...
@@ -32,8 +32,7 @@ module.exports = function (passport) {
new
LocalStrategy
({
usernameField
:
'email'
,
passwordField
:
'password'
},
(
uEmail
,
uPassword
,
done
)
=>
{
},
(
uEmail
,
uPassword
,
done
)
=>
{
db
.
User
.
findOne
({
email
:
uEmail
,
provider
:
'local'
}).
then
((
user
)
=>
{
if
(
user
)
{
return
user
.
validatePassword
(
uPassword
).
then
(()
=>
{
...
...
@@ -48,7 +47,7 @@ module.exports = function (passport) {
done
(
err
,
null
)
})
}
))
))
}
// Google ID
...
...
@@ -60,15 +59,14 @@ module.exports = function (passport) {
clientID
:
appconfig
.
auth
.
google
.
clientId
,
clientSecret
:
appconfig
.
auth
.
google
.
clientSecret
,
callbackURL
:
appconfig
.
host
+
'/login/google/callback'
},
(
accessToken
,
refreshToken
,
profile
,
cb
)
=>
{
},
(
accessToken
,
refreshToken
,
profile
,
cb
)
=>
{
db
.
User
.
processProfile
(
profile
).
then
((
user
)
=>
{
return
cb
(
null
,
user
)
||
true
}).
catch
((
err
)
=>
{
return
cb
(
err
,
null
)
||
true
})
}
))
))
}
// Microsoft Accounts
...
...
@@ -80,15 +78,14 @@ module.exports = function (passport) {
clientID
:
appconfig
.
auth
.
microsoft
.
clientId
,
clientSecret
:
appconfig
.
auth
.
microsoft
.
clientSecret
,
callbackURL
:
appconfig
.
host
+
'/login/ms/callback'
},
function
(
accessToken
,
refreshToken
,
profile
,
cb
)
{
},
function
(
accessToken
,
refreshToken
,
profile
,
cb
)
{
db
.
User
.
processProfile
(
profile
).
then
((
user
)
=>
{
return
cb
(
null
,
user
)
||
true
}).
catch
((
err
)
=>
{
return
cb
(
err
,
null
)
||
true
})
}
))
))
}
// Facebook
...
...
@@ -101,15 +98,14 @@ module.exports = function (passport) {
clientSecret
:
appconfig
.
auth
.
facebook
.
clientSecret
,
callbackURL
:
appconfig
.
host
+
'/login/facebook/callback'
,
profileFields
:
[
'id'
,
'displayName'
,
'email'
]
},
function
(
accessToken
,
refreshToken
,
profile
,
cb
)
{
},
function
(
accessToken
,
refreshToken
,
profile
,
cb
)
{
db
.
User
.
processProfile
(
profile
).
then
((
user
)
=>
{
return
cb
(
null
,
user
)
||
true
}).
catch
((
err
)
=>
{
return
cb
(
err
,
null
)
||
true
})
}
))
))
}
// GitHub
...
...
@@ -121,16 +117,15 @@ module.exports = function (passport) {
clientID
:
appconfig
.
auth
.
github
.
clientId
,
clientSecret
:
appconfig
.
auth
.
github
.
clientSecret
,
callbackURL
:
appconfig
.
host
+
'/login/github/callback'
,
scope
:
[
'user:email'
]
},
(
accessToken
,
refreshToken
,
profile
,
cb
)
=>
{
scope
:
[
'user:email'
]
},
(
accessToken
,
refreshToken
,
profile
,
cb
)
=>
{
db
.
User
.
processProfile
(
profile
).
then
((
user
)
=>
{
return
cb
(
null
,
user
)
||
true
}).
catch
((
err
)
=>
{
return
cb
(
err
,
null
)
||
true
})
}
))
))
}
// Slack
...
...
@@ -142,15 +137,14 @@ module.exports = function (passport) {
clientID
:
appconfig
.
auth
.
slack
.
clientId
,
clientSecret
:
appconfig
.
auth
.
slack
.
clientSecret
,
callbackURL
:
appconfig
.
host
+
'/login/slack/callback'
},
(
accessToken
,
refreshToken
,
profile
,
cb
)
=>
{
},
(
accessToken
,
refreshToken
,
profile
,
cb
)
=>
{
db
.
User
.
processProfile
(
profile
).
then
((
user
)
=>
{
return
cb
(
null
,
user
)
||
true
}).
catch
((
err
)
=>
{
return
cb
(
err
,
null
)
||
true
})
}
))
))
}
// LDAP
...
...
@@ -174,8 +168,7 @@ module.exports = function (passport) {
},
usernameField
:
'email'
,
passReqToCallback
:
false
},
(
profile
,
cb
)
=>
{
},
(
profile
,
cb
)
=>
{
profile
.
provider
=
'ldap'
profile
.
id
=
profile
.
dn
db
.
User
.
processProfile
(
profile
).
then
((
user
)
=>
{
...
...
@@ -184,7 +177,7 @@ module.exports = function (passport) {
return
cb
(
err
,
null
)
||
true
})
}
))
))
}
// AZURE AD
...
...
@@ -199,8 +192,7 @@ module.exports = function (passport) {
callbackURL
:
appconfig
.
host
+
'/login/azure/callback'
,
resource
:
appconfig
.
auth
.
azure
.
resource
,
tenant
:
appconfig
.
auth
.
azure
.
tenant
},
(
accessToken
,
refreshToken
,
params
,
profile
,
cb
)
=>
{
},
(
accessToken
,
refreshToken
,
params
,
profile
,
cb
)
=>
{
let
waadProfile
=
jwt
.
decode
(
params
.
id_token
)
waadProfile
.
id
=
waadProfile
.
oid
waadProfile
.
provider
=
'azure'
...
...
@@ -210,7 +202,7 @@ module.exports = function (passport) {
return
cb
(
err
,
null
)
||
true
})
}
))
))
}
// Create users for first-time
...
...
server/libs/db.js
View file @
a1b6dfb3
...
...
@@ -19,7 +19,7 @@ module.exports = {
*
* @return {Object} DB instance
*/
init
()
{
init
()
{
let
self
=
this
let
dbModelsPath
=
path
.
join
(
SERVERPATH
,
'models'
)
...
...
@@ -44,14 +44,14 @@ module.exports = {
// Load DB Models
fs
.
readdirSync
(
dbModelsPath
)
.
filter
(
function
(
file
)
{
return
(
file
.
indexOf
(
'.'
)
!==
0
)
})
.
forEach
(
function
(
file
)
{
let
modelName
=
_
.
upperFirst
(
_
.
camelCase
(
_
.
split
(
file
,
'.'
)[
0
]))
self
[
modelName
]
=
require
(
path
.
join
(
dbModelsPath
,
file
))
})
.
readdirSync
(
dbModelsPath
)
.
filter
(
function
(
file
)
{
return
(
file
.
indexOf
(
'.'
)
!==
0
)
})
.
forEach
(
function
(
file
)
{
let
modelName
=
_
.
upperFirst
(
_
.
camelCase
(
_
.
split
(
file
,
'.'
)[
0
]))
self
[
modelName
]
=
require
(
path
.
join
(
dbModelsPath
,
file
))
})
// Connect
...
...
server/libs/entries.js
View file @
a1b6dfb3
...
...
@@ -260,21 +260,21 @@ module.exports = {
return
db
.
Entry
.
findOneAndUpdate
({
_id
:
content
.
entryPath
},
{
_id
:
content
.
entryPath
,
title
:
content
.
meta
.
title
||
content
.
entryPath
,
subtitle
:
content
.
meta
.
subtitle
||
''
,
parentTitle
:
content
.
parent
.
title
||
''
,
parentPath
:
parentPath
,
isDirectory
:
false
,
isEntry
:
true
},
{
new
:
true
,
upsert
:
true
}).
then
(
result
=>
{
let
plainResult
=
result
.
toObject
()
plainResult
.
text
=
content
.
text
return
plainResult
})
_id
:
content
.
entryPath
,
title
:
content
.
meta
.
title
||
content
.
entryPath
,
subtitle
:
content
.
meta
.
subtitle
||
''
,
parentTitle
:
content
.
parent
.
title
||
''
,
parentPath
:
parentPath
,
isDirectory
:
false
,
isEntry
:
true
},
{
new
:
true
,
upsert
:
true
}).
then
(
result
=>
{
let
plainResult
=
result
.
toObject
()
plainResult
.
text
=
content
.
text
return
plainResult
})
}).
then
(
result
=>
{
return
self
.
updateTreeInfo
().
then
(()
=>
{
return
result
...
...
server/libs/search-index/index.js
View file @
a1b6dfb3
...
...
@@ -29,7 +29,7 @@ module.exports = function (givenOptions, moduleReady) {
const
getAdder
=
function
(
SearchIndex
,
done
)
{
SearchIndexAdder
(
SearchIndex
.
options
,
function
(
err
,
searchIndexAdder
)
{
SearchIndex
.
add
=
searchIndexAdder
.
add
SearchIndex
.
callbackyAdd
=
searchIndexAdder
.
concurrentAdd
// deprecated
SearchIndex
.
callbackyAdd
=
searchIndexAdder
.
concurrentAdd
// deprecated
SearchIndex
.
concurrentAdd
=
searchIndexAdder
.
concurrentAdd
SearchIndex
.
createWriteStream
=
searchIndexAdder
.
createWriteStream
SearchIndex
.
dbWriteStream
=
searchIndexAdder
.
dbWriteStream
...
...
server/libs/search.js
View file @
a1b6dfb3
...
...
@@ -157,15 +157,15 @@ module.exports = {
find
(
terms
)
{
let
self
=
this
terms
=
_
.
chain
(
terms
)
.
deburr
()
.
toLower
()
.
trim
()
.
replace
(
/
[^
a-z0-9
]
/g
,
' '
)
.
value
()
.
deburr
()
.
toLower
()
.
trim
()
.
replace
(
/
[^
a-z0-9
]
/g
,
' '
)
.
value
()
let
arrTerms
=
_
.
chain
(
terms
)
.
split
(
' '
)
.
filter
((
f
)
=>
{
return
!
_
.
isEmpty
(
f
)
})
.
value
()
.
split
(
' '
)
.
filter
((
f
)
=>
{
return
!
_
.
isEmpty
(
f
)
})
.
value
()
return
streamToPromise
(
self
.
_si
.
search
({
query
:
[{
...
...
server/libs/system.js
View file @
a1b6dfb3
...
...
@@ -46,21 +46,21 @@ module.exports = {
winston
.
info
(
'[SERVER.System] Install tarball found. Downloading...'
)
resp
.
pipe
(
zlib
.
createGunzip
())
.
pipe
(
tar
.
Extract
({
path
:
self
.
_installDir
}))
.
on
(
'error'
,
err
=>
reject
(
err
))
.
on
(
'end'
,
()
=>
{
winston
.
info
(
'[SERVER.System] Tarball extracted. Comparing files...'
)
/**
* Replace old files
*/
klaw
(
self
.
_installDir
)
.
pipe
(
tar
.
Extract
({
path
:
self
.
_installDir
}))
.
on
(
'error'
,
err
=>
reject
(
err
))
.
on
(
'end'
,
()
=>
{
winston
.
info
(
'[SERVER.System] All files were updated successfully.'
)
resolve
(
true
)
winston
.
info
(
'[SERVER.System] Tarball extracted. Comparing files...'
)
/**
* Replace old files
*/
klaw
(
self
.
_installDir
)
.
on
(
'error'
,
err
=>
reject
(
err
))
.
on
(
'end'
,
()
=>
{
winston
.
info
(
'[SERVER.System] All files were updated successfully.'
)
resolve
(
true
)
})
.
pipe
(
self
.
replaceFile
())
})
.
pipe
(
self
.
replaceFile
())
})
})
})
}).
then
(()
=>
{
...
...
@@ -119,12 +119,12 @@ module.exports = {
let
hash
=
crypto
.
createHash
(
'sha1'
)
hash
.
setEncoding
(
'hex'
)
fs
.
createReadStream
(
filePath
)
.
on
(
'error'
,
err
=>
{
reject
(
err
)
})
.
on
(
'end'
,
()
=>
{
hash
.
end
()
resolve
(
hash
.
read
())
})
.
pipe
(
hash
)
.
on
(
'error'
,
err
=>
{
reject
(
err
)
})
.
on
(
'end'
,
()
=>
{
hash
.
end
()
resolve
(
hash
.
read
())
})
.
pipe
(
hash
)
}).
catch
(
err
=>
{
if
(
err
.
code
===
'ENOENT'
)
{
return
'0'
...
...
server/libs/uploads-agent.js
View file @
a1b6dfb3
...
...
@@ -234,8 +234,8 @@ module.exports = {
generateThumbnail
(
sourcePath
,
destPath
)
{
return
jimp
.
read
(
sourcePath
).
then
(
img
=>
{
return
img
.
contain
(
150
,
150
)
.
write
(
destPath
)
.
contain
(
150
,
150
)
.
write
(
destPath
)
})
},
...
...
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