Skip to content

Commit 0a13b3f

Browse files
committed
1 parent 5ce8ea9 commit 0a13b3f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

spec/ProtectedFields.spec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,5 +1801,25 @@ describe('ProtectedFields', function () {
18011801
expect(results.length).toBe(1);
18021802
expect(results[0].id).toBe(user.id);
18031803
});
1804+
1805+
it('should deny query on protected field with falsy value', async function () {
1806+
const query = new Parse.Query(Parse.User);
1807+
query.withJSON({ where: { email: null } });
1808+
await expectAsync(query.find()).toBeRejectedWith(
1809+
jasmine.objectContaining({
1810+
code: Parse.Error.OPERATION_FORBIDDEN,
1811+
})
1812+
);
1813+
});
1814+
1815+
it('should deny query on protected field with falsy value via $or', async function () {
1816+
const query = new Parse.Query(Parse.User);
1817+
query.withJSON({ where: { $or: [{ email: null }] } });
1818+
await expectAsync(query.find()).toBeRejectedWith(
1819+
jasmine.objectContaining({
1820+
code: Parse.Error.OPERATION_FORBIDDEN,
1821+
})
1822+
);
1823+
});
18041824
});
18051825
});

src/RestQuery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ _UnsafeRestQuery.prototype.denyProtectedFields = async function () {
849849
) || [];
850850
const checkWhere = (where) => {
851851
for (const key of protectedFields) {
852-
if (where[key]) {
852+
if (key in where) {
853853
throw createSanitizedError(
854854
Parse.Error.OPERATION_FORBIDDEN,
855855
`This user is not allowed to query ${key} on class ${this.className}`,

0 commit comments

Comments
 (0)