Skip to content

Commit aaa34db

Browse files
committed
added master-key-only option when saving config
1 parent b40f3a1 commit aaa34db

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

integration/test/ParseConfigTest.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,9 @@ const clear = require('./clear');
55
const Parse = require('../../node');
66

77
function testConfig() {
8-
const data = {
9-
params: { internal: 'i', public: 'p' },
10-
masterKeyOnly: { internal: true },
11-
};
12-
return Parse.CoreManager.getRESTController().request(
13-
'PUT',
14-
'config',
15-
data,
16-
{ useMasterKey: true }
8+
return Parse.Config.save(
9+
{ internal: "i", public: "p" },
10+
{ internal: true }
1711
);
1812
}
1913

src/ParseConfig.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ class ParseConfig {
9595
* @return {Promise} A promise that is resolved with a newly-created
9696
* configuration object or with the current with the update.
9797
*/
98-
static save(attrs: { [key: string]: any }) {
98+
static save(attrs: { [key: string]: any }, masterKeyOnly: { [key: string]: any }) {
9999
const controller = CoreManager.getConfigController();
100100
//To avoid a mismatch with the local and the cloud config we get a new version
101-
return controller.save(attrs).then(() => {
101+
return controller.save(attrs, masterKeyOnly).then(() => {
102102
return controller.get();
103103
},(error) => {
104104
return Promise.reject(error);
@@ -184,16 +184,20 @@ const DefaultController = {
184184
});
185185
},
186186

187-
save(attrs: { [key: string]: any }) {
187+
save(attrs: { [key: string]: any }, masterKeyOnly: { [key: string]: any }) {
188188
const RESTController = CoreManager.getRESTController();
189189
const encodedAttrs = {};
190+
const encodedMasterKeyOnly = {};
190191
for(const key in attrs){
191192
encodedAttrs[key] = encode(attrs[key])
192193
}
194+
for(const key in masterKeyOnly){
195+
encodedMasterKeyOnly[key] = encode(masterKeyOnly[key])
196+
}
193197
return RESTController.request(
194198
'PUT',
195199
'config',
196-
{ params: encodedAttrs },
200+
{ params: encodedAttrs, masterKeyOnly: encodedMasterKeyOnly },
197201
{ useMasterKey: true }
198202
).then(response => {
199203
if(response && response.result){

0 commit comments

Comments
 (0)