parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

PushController validateMasterKey always returning false.

Open degenddy opened this issue 10 years ago • 9 comments

In PishController the method validateMasterKey always fails and so without disabling this check I can't send push notifications.

degenddy avatar Feb 22 '16 22:02 degenddy

Where are you sending push from? In parse-server, the master key must always be used, and push should not be sent from clients.

gfosco avatar Feb 22 '16 22:02 gfosco

Yes I'm sending from cloud code. I use the method Parse.useMasterKey() before calling the push method.

degenddy avatar Feb 22 '16 22:02 degenddy

the useMasterKey method doesn't work in cloud code. This was mentioned at the bottom of the readme, maybe we should put it back. The useMasterKey:true option must be passed to the options block of Parse.Push.send:

Parse.Push.send({
  where: query,
  data: { ... }
}, { useMasterKey: true });

added to wiki: https://github.com/ParsePlatform/parse-server/wiki/Push

gfosco avatar Feb 22 '16 23:02 gfosco

Oh ok, I'm sorry. I might have missed that. Is this true also for other things like saving objects with specific acl? How can I save an object I don't have authorization for, if so?

degenddy avatar Feb 23 '16 06:02 degenddy

You can pass the useMasterKey option to query and save calls:

object.save(null, { useMasterKey: true }).then(....

query.find({ useMasterKey: true }).then(....

gfosco avatar Feb 23 '16 06:02 gfosco

and for count()? count({useMasterKey: true}) ?

degenddy avatar Feb 23 '16 19:02 degenddy

also saveAll({useMasterKey: true}, objects) ?

degenddy avatar Feb 23 '16 19:02 degenddy

The count one looks right, but swap the parameter order for saveAll.

gfosco avatar Feb 23 '16 21:02 gfosco

Ok thanks!

degenddy avatar Feb 23 '16 21:02 degenddy