2017-09-30 22:47:14 -05:00
|
|
|
const _ = require('lodash')
|
|
|
|
const fs = require('fs-extra')
|
|
|
|
const path = require('path')
|
|
|
|
|
2018-03-05 14:49:36 -06:00
|
|
|
/* global WIKI */
|
2017-09-30 22:47:14 -05:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
Query: {
|
2018-03-05 14:49:36 -06:00
|
|
|
async authentication() { return {} }
|
|
|
|
},
|
|
|
|
Mutation: {
|
|
|
|
async authentication() { return {} }
|
|
|
|
},
|
|
|
|
AuthenticationQuery: {
|
|
|
|
providers(obj, args, context, info) {
|
2018-03-05 19:53:24 -06:00
|
|
|
return _.chain(WIKI.auth.strategies).map(str => {
|
|
|
|
return {
|
|
|
|
isEnabled: true,
|
|
|
|
key: str.key,
|
2018-03-05 22:13:20 -06:00
|
|
|
props: str.props,
|
2018-03-05 19:53:24 -06:00
|
|
|
title: str.title,
|
2018-03-05 22:13:20 -06:00
|
|
|
useForm: str.useForm,
|
|
|
|
config: []
|
2018-03-05 19:53:24 -06:00
|
|
|
}
|
|
|
|
}).sortBy(['title']).value()
|
2017-09-30 22:47:14 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
AuthenticationProvider: {
|
|
|
|
icon (ap, args) {
|
2018-03-05 19:53:24 -06:00
|
|
|
return fs.readFile(path.join(WIKI.ROOTPATH, `assets/svg/auth-icon-${ap.key}.svg`), 'utf8').catch(err => {
|
2017-09-30 22:47:14 -05:00
|
|
|
if (err.code === 'ENOENT') {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
throw err
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|