Skip to content

Commit

Permalink
chore: fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sbender9 committed Mar 31, 2021
1 parent a69a027 commit 4fdd292
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
38 changes: 24 additions & 14 deletions src/pipedproviders.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const deep = require('deep-get-set')
const DevNull = require('dev-null-stream')
const _ = require('lodash')

module.exports = function (app) {
module.exports = function(app) {
function createPipedProvider(providerConfig) {
const { propertyValues, ...sanitizedApp } = app
const emitPropertyValue = (name, value) =>
Expand All @@ -30,22 +30,29 @@ module.exports = function (app) {
})
const onPropertyValues = (name, cb) =>
app.propertyValues.onPropertyValues(name, cb)
const appFacade = { emitPropertyValue, onPropertyValues, ...sanitizedApp, toJSON: () => 'appFacade' }
const appFacade = {
emitPropertyValue,
onPropertyValues,
...sanitizedApp,
toJSON: () => 'appFacade'
}

const result = {
id: providerConfig.id,
pipeElements: providerConfig.pipeElements.reduce((res, config) => {
if (typeof config.enabled === 'undefined' || config.enabled) {
res.push(createPipeElement({
...config,
options: {
providerId: providerConfig.id,
app: appFacade,
...config.options,
emitPropertyValue,
onPropertyValues
}
}))
res.push(
createPipeElement({
...config,
options: {
providerId: providerConfig.id,
app: appFacade,
...config.options,
emitPropertyValue,
onPropertyValues
}
})
)
}
return res
}, [])
Expand All @@ -65,9 +72,12 @@ module.exports = function (app) {

function createPipeElement(elementConfig) {
if (elementConfig.optionMappings) {
elementConfig.optionMappings.forEach(function (mapping) {
elementConfig.optionMappings.forEach(function(mapping) {
if (deep(app, mapping.fromAppProperty)) {
elementConfig.options[mapping.toOption] = deep(app, mapping.fromAppProperty)
elementConfig.options[mapping.toOption] = deep(
app,
mapping.fromAppProperty
)
}
})
}
Expand Down
3 changes: 1 addition & 2 deletions src/serverroutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,9 @@ module.exports = function(app, saveSecurityConfig, getSecurityConfig) {

app.put(`${SERVERROUTESPREFIX}/security/config`, (req, res, next) => {
if (app.securityStrategy.allowConfigure(req)) {

try {
app.securityStrategy.validateConfiguration(req.body)
} catch ( err ) {
} catch (err) {
res.status(400).send(err.message)
return
}
Expand Down
6 changes: 3 additions & 3 deletions src/tokensecurity.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,15 @@ module.exports = function(app, config) {
})
})
}
strategy.validateConfiguration = ( newConfiguration ) => {

strategy.validateConfiguration = newConfiguration => {
const configuration = getConfiguration()
const theExpiration = newConfiguration.expiration || '1h'
jwt.sign('dummyPayload', configuration.secretKey, {
expiresIn: theExpiration
})
}

strategy.getAuthRequiredString = () => {
return strategy.allowReadOnly() ? 'forwrite' : 'always'
}
Expand Down

0 comments on commit 4fdd292

Please sign in to comment.