mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-01-20 20:01:25 +00:00
26 lines
545 B
JavaScript
26 lines
545 B
JavaScript
import { rule, shield, allow } from 'graphql-shield'
|
|
|
|
const isOwner = rule()(async (parent, args, ctx, info) => {
|
|
return ctx.user.id === parent.id
|
|
})
|
|
|
|
// Permissions
|
|
const permissions = shield({
|
|
Query: {
|
|
statistics: allow
|
|
// fruits: and(isAuthenticated, or(isAdmin, isModerator)),
|
|
// customers: and(isAuthenticated, isAdmin)
|
|
},
|
|
Mutation: {
|
|
// addFruitToBasket: isAuthenticated
|
|
// CreateUser: allow
|
|
},
|
|
User: {
|
|
email: isOwner,
|
|
password: isOwner
|
|
}
|
|
// Post: isAuthenticated
|
|
})
|
|
|
|
export default permissions
|