mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2026-01-15 17:34:38 +00:00
try to fix seeder with authentication
This commit is contained in:
parent
af57a6aa02
commit
8b0be5fb89
@ -7,7 +7,7 @@
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"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",
|
||||
"seedDb": "./node_modules/.bin/babel-node src/seed/seed-db.js"
|
||||
"seedDb": "cross-env IS_SEEDING='true' ./node_modules/.bin/babel-node src/seed/seed-db.js && cross-env IS_SEEDING=false"
|
||||
},
|
||||
"author": "Grzegorz Leoniec",
|
||||
"license": "MIT",
|
||||
@ -19,6 +19,7 @@
|
||||
"apollo-server": "^2.0.4",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"cheerio": "^1.0.0-rc.2",
|
||||
"cross-env": "^5.2.0",
|
||||
"date-fns": "^2.0.0-alpha.24",
|
||||
"dotenv": "^6.0.0",
|
||||
"graphql-custom-directives": "^0.2.13",
|
||||
|
||||
@ -3,28 +3,40 @@ import format from 'date-fns/format'
|
||||
export default {
|
||||
Mutation: {
|
||||
CreateUser: async (resolve, root, args, context, info) => {
|
||||
args.createdAt = format(new Date())
|
||||
try {
|
||||
args.createdAt = format(new Date())
|
||||
} catch (err) {}
|
||||
|
||||
args.disabled = false
|
||||
args.deleted = false
|
||||
const result = await resolve(root, args, context, info)
|
||||
return result
|
||||
},
|
||||
CreatePost: async (resolve, root, args, context, info) => {
|
||||
args.createdAt = format(new Date())
|
||||
try {
|
||||
args.createdAt = format(new Date())
|
||||
} catch (err) {}
|
||||
|
||||
args.disabled = false
|
||||
args.deleted = false
|
||||
const result = await resolve(root, args, context, info)
|
||||
return result
|
||||
},
|
||||
CreateComment: async (resolve, root, args, context, info) => {
|
||||
args.createdAt = format(new Date())
|
||||
try {
|
||||
args.createdAt = format(new Date())
|
||||
} catch (err) {}
|
||||
|
||||
args.disabled = false
|
||||
args.deleted = false
|
||||
const result = await resolve(root, args, context, info)
|
||||
return result
|
||||
},
|
||||
CreateOrganization: async (resolve, root, args, context, info) => {
|
||||
args.createdAt = format(new Date())
|
||||
try {
|
||||
args.createdAt = format(new Date())
|
||||
} catch (err) {}
|
||||
|
||||
args.disabled = false
|
||||
args.deleted = false
|
||||
const result = await resolve(root, args, context, info)
|
||||
|
||||
@ -1,16 +1,32 @@
|
||||
import { rule, shield, and, or, not, allow } from 'graphql-shield'
|
||||
|
||||
const isAuthenticated = rule()(async (parent, args, ctx, info) => {
|
||||
console.log('isSeeding', process.env.IS_SEEDING)
|
||||
if (process.env.IS_SEEDING === true) {
|
||||
return true
|
||||
}
|
||||
return ctx.user !== null
|
||||
})
|
||||
const isOwner = rule()(async (parent, args, ctx, info) => {
|
||||
console.log('isSeeding', process.env.IS_SEEDING)
|
||||
if (process.env.IS_SEEDING === true) {
|
||||
return true
|
||||
}
|
||||
console.log('parent', parent)
|
||||
return ctx.user.id === parent.id
|
||||
})
|
||||
const isAdmin = rule()(async (parent, args, ctx, info) => {
|
||||
console.log('isSeeding', process.env.IS_SEEDING)
|
||||
if (process.env.IS_SEEDING === true) {
|
||||
return true
|
||||
}
|
||||
return ctx.user.role === 'ADMIN'
|
||||
})
|
||||
const isModerator = rule()(async (parent, args, ctx, info) => {
|
||||
console.log('isSeeding', process.env.IS_SEEDING)
|
||||
if (process.env.IS_SEEDING === true) {
|
||||
return true
|
||||
}
|
||||
return ctx.user.role === 'MODERATOR'
|
||||
})
|
||||
|
||||
|
||||
28
yarn.lock
28
yarn.lock
@ -1405,6 +1405,14 @@ create-error-class@^3.0.0:
|
||||
dependencies:
|
||||
capture-stack-trace "^1.0.0"
|
||||
|
||||
cross-env@^5.2.0:
|
||||
version "5.2.0"
|
||||
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.2.0.tgz#6ecd4c015d5773e614039ee529076669b9d126f2"
|
||||
integrity sha512-jtdNFfFW1hB7sMhr/H6rW1Z45LFqyI431m3qU6bFXcQ3Eh7LtBuG3h74o7ohHZ3crrRkkqHlo4jYHFPcjroANg==
|
||||
dependencies:
|
||||
cross-spawn "^6.0.5"
|
||||
is-windows "^1.0.0"
|
||||
|
||||
cross-fetch@2.2.2:
|
||||
version "2.2.2"
|
||||
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-2.2.2.tgz#a47ff4f7fc712daba8f6a695a11c948440d45723"
|
||||
@ -1420,6 +1428,17 @@ cross-spawn@^5.0.1:
|
||||
shebang-command "^1.2.0"
|
||||
which "^1.2.9"
|
||||
|
||||
cross-spawn@^6.0.5:
|
||||
version "6.0.5"
|
||||
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
|
||||
integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==
|
||||
dependencies:
|
||||
nice-try "^1.0.4"
|
||||
path-key "^2.0.1"
|
||||
semver "^5.5.0"
|
||||
shebang-command "^1.2.0"
|
||||
which "^1.2.9"
|
||||
|
||||
crypto-random-string@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e"
|
||||
@ -2524,7 +2543,7 @@ is-symbol@^1.0.2:
|
||||
dependencies:
|
||||
has-symbols "^1.0.0"
|
||||
|
||||
is-windows@^1.0.2:
|
||||
is-windows@^1.0.0, is-windows@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
|
||||
|
||||
@ -2918,6 +2937,11 @@ neo4j-graphql-js@1.0.5:
|
||||
lodash "^4.17.10"
|
||||
neo4j-driver "^1.6.1"
|
||||
|
||||
nice-try@^1.0.4:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
|
||||
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==
|
||||
|
||||
node-fetch@1.6.3:
|
||||
version "1.6.3"
|
||||
resolved "http://registry.npmjs.org/node-fetch/-/node-fetch-1.6.3.tgz#dc234edd6489982d58e8f0db4f695029abcd8c04"
|
||||
@ -3203,7 +3227,7 @@ path-is-inside@^1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53"
|
||||
|
||||
path-key@^2.0.0:
|
||||
path-key@^2.0.0, path-key@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user