mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Implement authorization on Post mutations
This commit is contained in:
parent
f1dd52f579
commit
7a70b9ece4
@ -16,7 +16,7 @@ const isModerator = rule()(async (parent, args, ctx, info) => {
|
||||
})
|
||||
*/
|
||||
|
||||
const isOwner = rule({ cache: 'no_cache' })(async (parent, args, ctx, info) => {
|
||||
const myself = rule({ cache: 'no_cache' })(async (parent, args, ctx, info) => {
|
||||
return ctx.user.id === parent.id
|
||||
})
|
||||
|
||||
@ -28,13 +28,16 @@ const permissions = shield({
|
||||
// customers: and(isAuthenticated, isAdmin)
|
||||
},
|
||||
Mutation: {
|
||||
report: isAuthenticated
|
||||
CreatePost: isAuthenticated,
|
||||
// TODO UpdatePost: isOwner,
|
||||
// TODO DeletePost: isOwner,
|
||||
report: isAuthenticated,
|
||||
// addFruitToBasket: isAuthenticated
|
||||
// CreateUser: allow,
|
||||
},
|
||||
User: {
|
||||
email: isOwner,
|
||||
password: isOwner
|
||||
email: myself,
|
||||
password: myself
|
||||
}
|
||||
// Post: isAuthenticated
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user