fix: admin contribute list + source permission
This commit is contained in:
@@ -109,7 +109,7 @@ router.get(['/h', '/h/*'], async (req, res, next) => {
|
||||
|
||||
_.set(res, 'locals.siteConfig.lang', pageArgs.locale)
|
||||
|
||||
if (!WIKI.auth.checkAccess(req.user, ['read:pages'], pageArgs)) {
|
||||
if (!WIKI.auth.checkAccess(req.user, ['read:history'], pageArgs)) {
|
||||
_.set(res.locals, 'pageMeta.title', 'Unauthorized')
|
||||
return res.render('unauthorized', { action: 'history' })
|
||||
}
|
||||
@@ -182,7 +182,7 @@ router.get(['/s', '/s/*'], async (req, res, next) => {
|
||||
|
||||
_.set(res, 'locals.siteConfig.lang', pageArgs.locale)
|
||||
|
||||
if (!WIKI.auth.checkAccess(req.user, ['read:pages'], pageArgs)) {
|
||||
if (!WIKI.auth.checkAccess(req.user, ['read:source'], pageArgs)) {
|
||||
return res.render('unauthorized', { action: 'source' })
|
||||
}
|
||||
|
||||
|
@@ -1,31 +1,28 @@
|
||||
const request = require('request-promise')
|
||||
const _ = require('lodash')
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
module.exports = {
|
||||
Query: {
|
||||
async contribute() { return {} }
|
||||
},
|
||||
ContributeQuery: {
|
||||
async contributors(obj, args, context, info) {
|
||||
const resp = await request({
|
||||
uri: 'https://opencollective.com/wikijs/members/all.json',
|
||||
json: true
|
||||
})
|
||||
return _.filter(resp, c => {
|
||||
return c.role === 'BACKER' && c.totalAmountDonated > 0
|
||||
}).map(c => ({
|
||||
company: _.get(c, 'company', '') || '',
|
||||
currency: _.get(c, 'currency', 'USD') || 'USD',
|
||||
description: _.get(c, 'description', '') || '',
|
||||
id: _.get(c, 'MemberId', 0),
|
||||
image: _.get(c, 'image', '') || '',
|
||||
name: _.get(c, 'name', 'Anonymous') || '',
|
||||
profile: _.get(c, 'profile', ''),
|
||||
tier: _.toLower(_.get(c, 'tier', 'backers')),
|
||||
totalDonated: Math.ceil(_.get(c, 'totalAmountDonated', 0)),
|
||||
twitter: _.get(c, 'twitter', '') || '',
|
||||
website: _.get(c, 'website', '') || ''
|
||||
}))
|
||||
try {
|
||||
const resp = await request({
|
||||
method: 'POST',
|
||||
uri: 'https://graph.requarks.io',
|
||||
json: true,
|
||||
body: {
|
||||
query: '{\n sponsors {\n list(kind: BACKER) {\n id\n source\n name\n joined\n website\n twitter\n avatar\n }\n }\n}\n',
|
||||
variables: {}
|
||||
}
|
||||
})
|
||||
return _.get(resp, 'data.sponsors.list', [])
|
||||
} catch (err) {
|
||||
WIKI.logger.warn(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -19,15 +19,11 @@ type ContributeQuery {
|
||||
# -----------------------------------------------
|
||||
|
||||
type ContributeContributor {
|
||||
company: String!
|
||||
currency: String!
|
||||
description: String!
|
||||
id: Int!
|
||||
image: String!
|
||||
id: String!
|
||||
source: String!
|
||||
name: String!
|
||||
profile: String!
|
||||
tier: String!
|
||||
totalDonated: Int!
|
||||
twitter: String!
|
||||
website: String!
|
||||
joined: Date!
|
||||
website: String
|
||||
twitter: String
|
||||
avatar: String
|
||||
}
|
||||
|
Reference in New Issue
Block a user