feat: locale namespacing save + auth fetch fix
This commit is contained in:
@@ -15,18 +15,17 @@ module.exports = {
|
||||
async authentication() { return {} }
|
||||
},
|
||||
AuthenticationQuery: {
|
||||
providers(obj, args, context, info) {
|
||||
let prv = _.map(WIKI.auth.strategies, str => ({
|
||||
isEnabled: str.config.isEnabled,
|
||||
key: str.key,
|
||||
props: str.props,
|
||||
title: str.title,
|
||||
useForm: str.useForm,
|
||||
config: []
|
||||
async providers(obj, args, context, info) {
|
||||
let strategies = await WIKI.db.authentication.query().orderBy('title')
|
||||
strategies = strategies.map(stg => ({
|
||||
...stg,
|
||||
config: _.transform(stg.config, (res, value, key) => {
|
||||
res.push({ key, value })
|
||||
}, [])
|
||||
}))
|
||||
if (args.filter) { prv = graphHelper.filter(prv, args.filter) }
|
||||
if (args.orderBy) { prv = graphHelper.orderBy(prv, args.orderBy) }
|
||||
return prv
|
||||
if (args.filter) { strategies = graphHelper.filter(strategies, args.filter) }
|
||||
if (args.orderBy) { strategies = graphHelper.orderBy(strategies, args.orderBy) }
|
||||
return strategies
|
||||
}
|
||||
},
|
||||
AuthenticationMutation: {
|
||||
|
@@ -26,8 +26,10 @@ module.exports = {
|
||||
},
|
||||
async config(obj, args, context, info) {
|
||||
return {
|
||||
locale: WIKI.config.site.lang,
|
||||
autoUpdate: WIKI.config.site.langAutoUpdate
|
||||
locale: WIKI.config.lang.code,
|
||||
autoUpdate: WIKI.config.lang.autoUpdate,
|
||||
namespacing: WIKI.config.lang.namespacing,
|
||||
namespaces: WIKI.config.lang.namespaces
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -49,9 +51,11 @@ module.exports = {
|
||||
},
|
||||
async updateLocale(obj, args, context) {
|
||||
try {
|
||||
WIKI.config.site.lang = args.locale
|
||||
WIKI.config.site.langAutoUpdate = args.autoUpdate
|
||||
await WIKI.configSvc.saveToDb(['site'])
|
||||
WIKI.config.lang.code = args.locale
|
||||
WIKI.config.lang.autoUpdate = args.autoUpdate
|
||||
WIKI.config.lang.namespacing = args.namespacing
|
||||
WIKI.config.lang.namespaces = args.namespaces
|
||||
await WIKI.configSvc.saveToDb(['lang'])
|
||||
|
||||
await WIKI.lang.setCurrentLocale(args.locale)
|
||||
|
||||
|
Reference in New Issue
Block a user