Robert Schäfer 2018-12-04 21:41:19 +01:00
parent 0fab314b13
commit 43b5d8eeb0
2 changed files with 21 additions and 5 deletions

View File

@ -3,16 +3,18 @@
"version": "0.0.1",
"description": "GraphQL Backend for Human Connection",
"main": "src/index.js",
"config": {
"no_auth": "cross-env GRAPHQL_URI=http://localhost:4001 GRAPHQL_PORT=4001 PERMISSIONS=disabled"
},
"scripts": {
"eslint": "eslint src --config .eslintrc.js",
"test": "echo \"Error: no test specified\" && exit 0",
"start": "./node_modules/.bin/nodemon --exec babel-node src/index.js",
"start:debug": "./node_modules/.bin/nodemon --exec babel-node --inspect=0.0.0.0:9229 src/index.js",
"db:no-auth-server": "cross-env GRAPHQL_URI=http://localhost:4001 PERMISSIONS=disabled GRAPHQL_PORT=4001 yarn run start",
"db:script:seed": "wait-on tcp:4001 && cross-env GRAPHQL_URI=http://localhost:4001 ./node_modules/.bin/babel-node src/seed/seed-db.js",
"db:script:reset": "wait-on tcp:4001 && cross-env GRAPHQL_URI=http://localhost:4001 ./node_modules/.bin/babel-node src/seed/reset-db.js",
"db:seed": "concurrently --kill-others --success first -n no-auth-server,seed \"yarn run db:no-auth-server\" \"yarn run db:script:seed\"",
"db:reset": "concurrently --kill-others --success first -n no-auth-server,reset \"yarn run db:no-auth-server\" \"yarn run db:script:reset\""
"db:script:seed": "wait-on tcp:4001 && $npm_package_config_no_auth ./node_modules/.bin/babel-node src/seed/seed-db.js",
"db:script:reset": "wait-on tcp:4001 && $npm_package_config_no_auth ./node_modules/.bin/babel-node src/seed/reset-db.js",
"db:seed": "concurrently --kill-others --success first -n no-auth-server,seed '$npm_package_config_no_auth yarn run start' 'yarn run db:script:seed'",
"db:reset": "concurrently --kill-others --success first -n no-auth-server,reset '$npm_package_config_no_auth yarn run start' 'yarn run db:script:reset'"
},
"author": "Human Connection gGmbH",
"license": "MIT",

View File

@ -1,5 +1,19 @@
import { rule, shield, allow } from 'graphql-shield'
/*
* TODO: implement
* See: https://github.com/Human-Connection/Nitro-Backend/pull/40#pullrequestreview-180898363
const isAuthenticated = rule()(async (parent, args, ctx, info) => {
return ctx.user !== null
})
const isAdmin = rule()(async (parent, args, ctx, info) => {
return ctx.user.role === 'ADMIN'
})
const isModerator = rule()(async (parent, args, ctx, info) => {
return ctx.user.role === 'MODERATOR'
})
*/
const isOwner = rule()(async (parent, args, ctx, info) => {
return ctx.user.id === parent.id
})