fix: Incorrect indentation (eslint)

pull/166/head
NGPixel 8 years ago committed by Nicolas Giard
parent f37cbac332
commit a1b6dfb308

@ -1,8 +1,8 @@
{ {
"eslint.enable": true, "eslint.enable": true,
"eslint.autoFixOnSave": false, "eslint.autoFixOnSave": true,
"puglint.enable": true, "puglint.enable": true,
"standard.enable": false, "standard.enable": false,
"editor.formatOnSave": true, "editor.formatOnSave": false,
"editor.tabSize": 2 "editor.tabSize": 2
} }

@ -32,8 +32,7 @@ module.exports = function (passport) {
new LocalStrategy({ new LocalStrategy({
usernameField: 'email', usernameField: 'email',
passwordField: 'password' passwordField: 'password'
}, }, (uEmail, uPassword, done) => {
(uEmail, uPassword, done) => {
db.User.findOne({ email: uEmail, provider: 'local' }).then((user) => { db.User.findOne({ email: uEmail, provider: 'local' }).then((user) => {
if (user) { if (user) {
return user.validatePassword(uPassword).then(() => { return user.validatePassword(uPassword).then(() => {
@ -48,7 +47,7 @@ module.exports = function (passport) {
done(err, null) done(err, null)
}) })
} }
)) ))
} }
// Google ID // Google ID
@ -60,15 +59,14 @@ module.exports = function (passport) {
clientID: appconfig.auth.google.clientId, clientID: appconfig.auth.google.clientId,
clientSecret: appconfig.auth.google.clientSecret, clientSecret: appconfig.auth.google.clientSecret,
callbackURL: appconfig.host + '/login/google/callback' callbackURL: appconfig.host + '/login/google/callback'
}, }, (accessToken, refreshToken, profile, cb) => {
(accessToken, refreshToken, profile, cb) => {
db.User.processProfile(profile).then((user) => { db.User.processProfile(profile).then((user) => {
return cb(null, user) || true return cb(null, user) || true
}).catch((err) => { }).catch((err) => {
return cb(err, null) || true return cb(err, null) || true
}) })
} }
)) ))
} }
// Microsoft Accounts // Microsoft Accounts
@ -80,15 +78,14 @@ module.exports = function (passport) {
clientID: appconfig.auth.microsoft.clientId, clientID: appconfig.auth.microsoft.clientId,
clientSecret: appconfig.auth.microsoft.clientSecret, clientSecret: appconfig.auth.microsoft.clientSecret,
callbackURL: appconfig.host + '/login/ms/callback' callbackURL: appconfig.host + '/login/ms/callback'
}, }, function (accessToken, refreshToken, profile, cb) {
function (accessToken, refreshToken, profile, cb) {
db.User.processProfile(profile).then((user) => { db.User.processProfile(profile).then((user) => {
return cb(null, user) || true return cb(null, user) || true
}).catch((err) => { }).catch((err) => {
return cb(err, null) || true return cb(err, null) || true
}) })
} }
)) ))
} }
// Facebook // Facebook
@ -101,15 +98,14 @@ module.exports = function (passport) {
clientSecret: appconfig.auth.facebook.clientSecret, clientSecret: appconfig.auth.facebook.clientSecret,
callbackURL: appconfig.host + '/login/facebook/callback', callbackURL: appconfig.host + '/login/facebook/callback',
profileFields: ['id', 'displayName', 'email'] profileFields: ['id', 'displayName', 'email']
}, }, function (accessToken, refreshToken, profile, cb) {
function (accessToken, refreshToken, profile, cb) {
db.User.processProfile(profile).then((user) => { db.User.processProfile(profile).then((user) => {
return cb(null, user) || true return cb(null, user) || true
}).catch((err) => { }).catch((err) => {
return cb(err, null) || true return cb(err, null) || true
}) })
} }
)) ))
} }
// GitHub // GitHub
@ -121,16 +117,15 @@ module.exports = function (passport) {
clientID: appconfig.auth.github.clientId, clientID: appconfig.auth.github.clientId,
clientSecret: appconfig.auth.github.clientSecret, clientSecret: appconfig.auth.github.clientSecret,
callbackURL: appconfig.host + '/login/github/callback', callbackURL: appconfig.host + '/login/github/callback',
scope: [ 'user:email' ] scope: ['user:email']
}, }, (accessToken, refreshToken, profile, cb) => {
(accessToken, refreshToken, profile, cb) => {
db.User.processProfile(profile).then((user) => { db.User.processProfile(profile).then((user) => {
return cb(null, user) || true return cb(null, user) || true
}).catch((err) => { }).catch((err) => {
return cb(err, null) || true return cb(err, null) || true
}) })
} }
)) ))
} }
// Slack // Slack
@ -142,15 +137,14 @@ module.exports = function (passport) {
clientID: appconfig.auth.slack.clientId, clientID: appconfig.auth.slack.clientId,
clientSecret: appconfig.auth.slack.clientSecret, clientSecret: appconfig.auth.slack.clientSecret,
callbackURL: appconfig.host + '/login/slack/callback' callbackURL: appconfig.host + '/login/slack/callback'
}, }, (accessToken, refreshToken, profile, cb) => {
(accessToken, refreshToken, profile, cb) => {
db.User.processProfile(profile).then((user) => { db.User.processProfile(profile).then((user) => {
return cb(null, user) || true return cb(null, user) || true
}).catch((err) => { }).catch((err) => {
return cb(err, null) || true return cb(err, null) || true
}) })
} }
)) ))
} }
// LDAP // LDAP
@ -174,8 +168,7 @@ module.exports = function (passport) {
}, },
usernameField: 'email', usernameField: 'email',
passReqToCallback: false passReqToCallback: false
}, }, (profile, cb) => {
(profile, cb) => {
profile.provider = 'ldap' profile.provider = 'ldap'
profile.id = profile.dn profile.id = profile.dn
db.User.processProfile(profile).then((user) => { db.User.processProfile(profile).then((user) => {
@ -184,7 +177,7 @@ module.exports = function (passport) {
return cb(err, null) || true return cb(err, null) || true
}) })
} }
)) ))
} }
// AZURE AD // AZURE AD
@ -199,8 +192,7 @@ module.exports = function (passport) {
callbackURL: appconfig.host + '/login/azure/callback', callbackURL: appconfig.host + '/login/azure/callback',
resource: appconfig.auth.azure.resource, resource: appconfig.auth.azure.resource,
tenant: appconfig.auth.azure.tenant tenant: appconfig.auth.azure.tenant
}, }, (accessToken, refreshToken, params, profile, cb) => {
(accessToken, refreshToken, params, profile, cb) => {
let waadProfile = jwt.decode(params.id_token) let waadProfile = jwt.decode(params.id_token)
waadProfile.id = waadProfile.oid waadProfile.id = waadProfile.oid
waadProfile.provider = 'azure' waadProfile.provider = 'azure'
@ -210,7 +202,7 @@ module.exports = function (passport) {
return cb(err, null) || true return cb(err, null) || true
}) })
} }
)) ))
} }
// Create users for first-time // Create users for first-time

@ -19,7 +19,7 @@ module.exports = {
* *
* @return {Object} DB instance * @return {Object} DB instance
*/ */
init () { init() {
let self = this let self = this
let dbModelsPath = path.join(SERVERPATH, 'models') let dbModelsPath = path.join(SERVERPATH, 'models')
@ -44,14 +44,14 @@ module.exports = {
// Load DB Models // Load DB Models
fs fs
.readdirSync(dbModelsPath) .readdirSync(dbModelsPath)
.filter(function (file) { .filter(function (file) {
return (file.indexOf('.') !== 0) return (file.indexOf('.') !== 0)
}) })
.forEach(function (file) { .forEach(function (file) {
let modelName = _.upperFirst(_.camelCase(_.split(file, '.')[0])) let modelName = _.upperFirst(_.camelCase(_.split(file, '.')[0]))
self[modelName] = require(path.join(dbModelsPath, file)) self[modelName] = require(path.join(dbModelsPath, file))
}) })
// Connect // Connect

@ -260,21 +260,21 @@ module.exports = {
return db.Entry.findOneAndUpdate({ return db.Entry.findOneAndUpdate({
_id: content.entryPath _id: content.entryPath
}, { }, {
_id: content.entryPath, _id: content.entryPath,
title: content.meta.title || content.entryPath, title: content.meta.title || content.entryPath,
subtitle: content.meta.subtitle || '', subtitle: content.meta.subtitle || '',
parentTitle: content.parent.title || '', parentTitle: content.parent.title || '',
parentPath: parentPath, parentPath: parentPath,
isDirectory: false, isDirectory: false,
isEntry: true isEntry: true
}, { }, {
new: true, new: true,
upsert: true upsert: true
}).then(result => { }).then(result => {
let plainResult = result.toObject() let plainResult = result.toObject()
plainResult.text = content.text plainResult.text = content.text
return plainResult return plainResult
}) })
}).then(result => { }).then(result => {
return self.updateTreeInfo().then(() => { return self.updateTreeInfo().then(() => {
return result return result

@ -29,7 +29,7 @@ module.exports = function (givenOptions, moduleReady) {
const getAdder = function (SearchIndex, done) { const getAdder = function (SearchIndex, done) {
SearchIndexAdder(SearchIndex.options, function (err, searchIndexAdder) { SearchIndexAdder(SearchIndex.options, function (err, searchIndexAdder) {
SearchIndex.add = searchIndexAdder.add SearchIndex.add = searchIndexAdder.add
SearchIndex.callbackyAdd = searchIndexAdder.concurrentAdd // deprecated SearchIndex.callbackyAdd = searchIndexAdder.concurrentAdd // deprecated
SearchIndex.concurrentAdd = searchIndexAdder.concurrentAdd SearchIndex.concurrentAdd = searchIndexAdder.concurrentAdd
SearchIndex.createWriteStream = searchIndexAdder.createWriteStream SearchIndex.createWriteStream = searchIndexAdder.createWriteStream
SearchIndex.dbWriteStream = searchIndexAdder.dbWriteStream SearchIndex.dbWriteStream = searchIndexAdder.dbWriteStream

@ -157,15 +157,15 @@ module.exports = {
find (terms) { find (terms) {
let self = this let self = this
terms = _.chain(terms) terms = _.chain(terms)
.deburr() .deburr()
.toLower() .toLower()
.trim() .trim()
.replace(/[^a-z0-9 ]/g, ' ') .replace(/[^a-z0-9 ]/g, ' ')
.value() .value()
let arrTerms = _.chain(terms) let arrTerms = _.chain(terms)
.split(' ') .split(' ')
.filter((f) => { return !_.isEmpty(f) }) .filter((f) => { return !_.isEmpty(f) })
.value() .value()
return streamToPromise(self._si.search({ return streamToPromise(self._si.search({
query: [{ query: [{

@ -46,21 +46,21 @@ module.exports = {
winston.info('[SERVER.System] Install tarball found. Downloading...') winston.info('[SERVER.System] Install tarball found. Downloading...')
resp.pipe(zlib.createGunzip()) resp.pipe(zlib.createGunzip())
.pipe(tar.Extract({ path: self._installDir })) .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)
.on('error', err => reject(err)) .on('error', err => reject(err))
.on('end', () => { .on('end', () => {
winston.info('[SERVER.System] All files were updated successfully.') winston.info('[SERVER.System] Tarball extracted. Comparing files...')
resolve(true) /**
* 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(() => { }).then(() => {
@ -119,12 +119,12 @@ module.exports = {
let hash = crypto.createHash('sha1') let hash = crypto.createHash('sha1')
hash.setEncoding('hex') hash.setEncoding('hex')
fs.createReadStream(filePath) fs.createReadStream(filePath)
.on('error', err => { reject(err) }) .on('error', err => { reject(err) })
.on('end', () => { .on('end', () => {
hash.end() hash.end()
resolve(hash.read()) resolve(hash.read())
}) })
.pipe(hash) .pipe(hash)
}).catch(err => { }).catch(err => {
if (err.code === 'ENOENT') { if (err.code === 'ENOENT') {
return '0' return '0'

@ -234,8 +234,8 @@ module.exports = {
generateThumbnail (sourcePath, destPath) { generateThumbnail (sourcePath, destPath) {
return jimp.read(sourcePath).then(img => { return jimp.read(sourcePath).then(img => {
return img return img
.contain(150, 150) .contain(150, 150)
.write(destPath) .write(destPath)
}) })
}, },

Loading…
Cancel
Save