feat: vue-apollo + auth providers resolver (wip)

This commit is contained in:
NGPixel
2018-03-05 20:53:24 -05:00
parent 91b575529c
commit f5fb21aaba
14 changed files with 158 additions and 558 deletions

View File

@@ -13,28 +13,19 @@ module.exports = {
},
AuthenticationQuery: {
providers(obj, args, context, info) {
switch (args.mode) {
case 'active':
let strategies = _.chain(WIKI.auth.strategies).map(str => {
return {
key: str.key,
title: str.title,
useForm: str.useForm
}
}).sortBy(['title']).value()
let localStrategy = _.remove(strategies, str => str.key === 'local')
return _.concat(localStrategy, strategies)
case 'all':
break
default:
return null
}
return _.chain(WIKI.auth.strategies).map(str => {
return {
isEnabled: true,
key: str.key,
title: str.title,
useForm: str.useForm
}
}).sortBy(['title']).value()
}
},
AuthenticationProvider: {
icon (ap, args) {
return fs.readFileAsync(path.join(WIKI.ROOTPATH, `assets/svg/auth-icon-${ap.key}.svg`), 'utf8').catch(err => {
return fs.readFile(path.join(WIKI.ROOTPATH, `assets/svg/auth-icon-${ap.key}.svg`), 'utf8').catch(err => {
if (err.code === 'ENOENT') {
return null
}