Skip to content

Commit b2a8292

Browse files
committed
Remove useless masterKey validation in PushController.sendPush.
1 parent 4b0f84e commit b2a8292

File tree

2 files changed

+1
-38
lines changed

2 files changed

+1
-38
lines changed

Diff for: spec/PushController.spec.js

-25
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,6 @@ var PushController = require('../src/Controllers/PushController').PushController
33
var Config = require('../src/Config');
44

55
describe('PushController', () => {
6-
it('can check valid master key of request', (done) => {
7-
// Make mock request
8-
var auth = {
9-
isMaster: true
10-
}
11-
12-
expect(() => {
13-
PushController.validateMasterKey(auth);
14-
}).not.toThrow();
15-
done();
16-
});
17-
18-
it('can check invalid master key of request', (done) => {
19-
// Make mock request
20-
var auth = {
21-
isMaster: false
22-
}
23-
24-
expect(() => {
25-
PushController.validateMasterKey(auth);
26-
}).toThrow();
27-
done();
28-
});
29-
30-
316
it('can validate device type when no device type is set', (done) => {
327
// Make query condition
338
var where = {

Diff for: src/Controllers/PushController.js

+1-13
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,13 @@ export class PushController extends AdaptableController {
3636
}
3737
}
3838
}
39-
40-
/**
41-
* Check whether the api call has master key or not.
42-
* @param {Object} request A request object
43-
*/
44-
static validateMasterKey(auth = {}) {
45-
if (!auth.isMaster) {
46-
throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED,
47-
'Master key is invalid, you should only use master key to send push');
48-
}
49-
}
5039

5140
sendPush(body = {}, where = {}, config, auth) {
5241
var pushAdapter = this.adapter;
5342
if (!pushAdapter) {
5443
throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED,
5544
'Push adapter is not available');
5645
}
57-
PushController.validateMasterKey(auth);
5846
PushController.validatePushType(where, pushAdapter.getValidPushTypes());
5947
// Replace the expiration_time with a valid Unix epoch milliseconds time
6048
body['expiration_time'] = PushController.getExpirationTime(body);
@@ -140,6 +128,6 @@ export class PushController extends AdaptableController {
140128
expectedAdapterType() {
141129
return PushAdapter;
142130
}
143-
};
131+
}
144132

145133
export default PushController;

0 commit comments

Comments
 (0)