fix: handle removed auth strategies

This commit is contained in:
NGPixel
2020-08-30 16:33:52 -04:00
parent e319355017
commit 4dcf664040
4 changed files with 43 additions and 98 deletions

View File

@@ -93,6 +93,11 @@ module.exports = class Authentication extends Model {
for (const strategy of dbStrategies) {
const strategyDef = _.find(WIKI.data.authentication, ['key', strategy.strategyKey])
if (!strategyDef) {
await WIKI.models.authentication.query().delete().where('key', strategy.key)
WIKI.logger.info(`Authentication strategy ${strategy.strategyKey} was removed from disk: [ REMOVED ]`)
continue
}
strategy.config = _.transform(strategyDef.props, (result, value, key) => {
if (!_.has(result, key)) {
_.set(result, key, value.default)