1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const _ = require('lodash')
const fs = require('fs-extra')
const path = require('path')
/* global wiki */
module.exports = {
Query: {
authentication(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
}
}
},
Mutation: {},
AuthenticationProvider: {
icon (ap, args) {
return fs.readFileAsync(path.join(wiki.ROOTPATH, `assets/svg/auth-icon-${ap.key}.svg`), 'utf8').catch(err => {
if (err.code === 'ENOENT') {
return null
}
throw err
})
}
}
}