fix: code linting

This commit is contained in:
Nick
2019-09-08 12:39:05 -04:00
parent 7634bd266d
commit 69e644e18f
13 changed files with 1114 additions and 2386 deletions

View File

@@ -120,8 +120,8 @@ module.exports = {
} else {
res.cookie('jwt', newToken.token, { expires: moment().add(365, 'days').toDate() })
}
} catch (err) {
WIKI.logger.warn(err)
} catch (errc) {
WIKI.logger.warn(errc)
return next()
}
}
@@ -137,8 +137,8 @@ module.exports = {
}
// JWT is valid
req.logIn(user, { session: false }, (err) => {
if (err) { return next(err) }
req.logIn(user, { session: false }, (errc) => {
if (errc) { return next(errc) }
next()
})
})(req, res, next)

View File

@@ -45,8 +45,8 @@ module.exports = {
_.set(lcObj, key.replace(':', '.'), value)
})
const localeExists = await WIKI.models.locales.query().select('code').where('code', locale.code).first()
if (localeExists) {
const localeDbExists = await WIKI.models.locales.query().select('code').where('code', locale.code).first()
if (localeDbExists) {
await WIKI.models.locales.query().update({
code: locale.code,
strings: lcObj,

View File

@@ -71,8 +71,8 @@ module.exports = {
}))
resolve(true)
} catch (err) {
reject(err)
} catch (errc) {
reject(errc)
}
db.close()
})

View File

@@ -291,8 +291,8 @@ module.exports = class User extends Model {
mustChangePwd: true,
continuationToken: pwdChangeToken
})
} catch (err) {
WIKI.logger.warn(err)
} catch (errc) {
WIKI.logger.warn(errc)
return reject(new WIKI.Error.AuthGenericError())
}
}
@@ -308,14 +308,14 @@ module.exports = class User extends Model {
tfaRequired: true,
continuationToken: tfaToken
})
} catch (err) {
WIKI.logger.warn(err)
} catch (errc) {
WIKI.logger.warn(errc)
return reject(new WIKI.Error.AuthGenericError())
}
}
context.req.logIn(user, { session: !strInfo.useForm }, async err => {
if (err) { return reject(err) }
context.req.logIn(user, { session: !strInfo.useForm }, async errc => {
if (errc) { return reject(errc) }
const jwtToken = await WIKI.models.users.refreshToken(user)
resolve({ jwt: jwtToken.token })
})

View File

@@ -31,22 +31,22 @@ module.exports = {
builder.andWhere('path', 'like', `${opts.path}%`)
}
// TODO: Add user permissions filtering
builder.andWhere(builder => {
builder.andWhere(builderSub => {
switch (WIKI.config.db.type) {
case 'postgres':
builder.where('title', 'ILIKE', `%${q}%`)
builder.orWhere('description', 'ILIKE', `%${q}%`)
builderSub.where('title', 'ILIKE', `%${q}%`)
builderSub.orWhere('description', 'ILIKE', `%${q}%`)
break
case 'mysql':
case 'mariadb':
builder.whereRaw(`title LIKE '%?%' COLLATE utf8_general_ci`, [q])
builder.orWhereRaw(`description LIKE '%?%' COLLATE utf8_general_ci`, [q])
builderSub.whereRaw(`title LIKE '%?%' COLLATE utf8_general_ci`, [q])
builderSub.orWhereRaw(`description LIKE '%?%' COLLATE utf8_general_ci`, [q])
break
// TODO: MSSQL handling
default:
builder.where('title', 'LIKE', `%${q}%`)
builder.orWhere('description', 'LIKE', `%${q}%`)
builderSub.where('title', 'LIKE', `%${q}%`)
builderSub.orWhere('description', 'LIKE', `%${q}%`)
break
}
})