mirror of https://github.com/requarks/wiki
parent
51f5c236d6
commit
501f0a9a53
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 729 B |
@ -0,0 +1,22 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export default {
|
||||
GQL_QUERY_AUTHENTICATION: gql`
|
||||
query($mode: String!) {
|
||||
authentication(mode:$mode) {
|
||||
key
|
||||
useForm
|
||||
title
|
||||
icon
|
||||
}
|
||||
}
|
||||
`,
|
||||
GQL_QUERY_TRANSLATIONS: gql`
|
||||
query($locale: String!, $namespace: String!) {
|
||||
translations(locale:$locale, namespace:$namespace) {
|
||||
key
|
||||
value
|
||||
}
|
||||
}
|
||||
`
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
import GRAPHQL from './graphql'
|
||||
|
||||
export default {
|
||||
GRAPHQL
|
||||
}
|
@ -0,0 +1,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
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue