@@ -351,19 +351,17 @@ class ParseLiveQueryServer {
351
351
if ( fromCache ) {
352
352
return fromCache ;
353
353
}
354
- try {
355
- const authPromise = getAuthForSessionToken ( { cacheController : this . cacheController , sessionToken : sessionToken } )
356
- . then ( ( auth ) => {
357
- return { auth, userId : auth && auth . user && auth . user . id } ;
358
- } , ( ) => {
359
- // If you can't continue, let's just wrap it up and delete it.
360
- // Next time, one will try again
361
- this . authCache . del ( sessionToken ) ;
362
- } ) ;
363
- this . authCache . set ( sessionToken , authPromise ) ;
364
- return authPromise ;
365
- } catch ( e ) { /* ignore errors */ }
366
- return Promise . resolve ( { } ) ;
354
+ const authPromise = getAuthForSessionToken ( { cacheController : this . cacheController , sessionToken : sessionToken } )
355
+ . then ( ( auth ) => {
356
+ return { auth, userId : auth && auth . user && auth . user . id } ;
357
+ } , ( ) => {
358
+ // If you can't continue, let's just wrap it up and delete it.
359
+ // Next time, one will try again
360
+ this . authCache . del ( sessionToken ) ;
361
+ return { } ;
362
+ } ) ;
363
+ this . authCache . set ( sessionToken , authPromise ) ;
364
+ return authPromise ;
367
365
}
368
366
369
367
async _matchesCLP ( classLevelPermissions : ?any , object : any , client : any , requestId : number , op : string) : any {
@@ -379,10 +377,10 @@ class ParseLiveQueryServer {
379
377
}
380
378
try {
381
379
await SchemaController . validatePermission ( classLevelPermissions , object . className , aclGroup , op ) ;
382
- return Promise . resolve ( true ) ;
380
+ return true ;
383
381
} catch ( e ) {
384
382
logger . verbose ( `Failed matching CLP for ${ object . id } ${ userId } ${ e } ` ) ;
385
- return Promise . resolve ( false ) ;
383
+ return false ;
386
384
}
387
385
// TODO: handle roles permissions
388
386
// Object.keys(classLevelPermissions).forEach((key) => {
@@ -403,22 +401,22 @@ class ParseLiveQueryServer {
403
401
&& typeof query . objectId === 'string' ? 'get' : 'find' ;
404
402
}
405
403
406
- async _matchesACL ( acl : any , client : any , requestId : number) : any {
404
+ async _matchesACL ( acl : any , client : any , requestId : number) : Promise < boolean > {
407
405
// Return true directly if ACL isn't present, ACL is public read, or client has master key
408
406
if ( ! acl || acl . getPublicReadAccess ( ) || client . hasMasterKey ) {
409
- return Promise . resolve ( true ) ;
407
+ return true ;
410
408
}
411
409
// Check subscription sessionToken matches ACL first
412
410
const subscriptionInfo = client . getSubscriptionInfo ( requestId ) ;
413
411
if ( typeof subscriptionInfo === 'undefined' ) {
414
- return Promise . resolve ( false ) ;
412
+ return false ;
415
413
}
416
414
417
415
// TODO: get auth there and de-duplicate code below to work with the same Auth obj.
418
416
const { auth , userId } = await this . getAuthForSessionToken ( subscriptionInfo . sessionToken ) ;
419
417
const isSubscriptionSessionTokenMatched = acl . getReadAccess ( userId ) ;
420
418
if ( isSubscriptionSessionTokenMatched ) {
421
- return Promise . resolve ( true ) ;
419
+ return true ;
422
420
}
423
421
424
422
// Check if the user has any roles that match the ACL
@@ -453,8 +451,7 @@ class ParseLiveQueryServer {
453
451
} else {
454
452
return isRoleMatched ;
455
453
}
456
- } ) . catch ( ( error ) => {
457
- error ;
454
+ } ) . catch ( ( ) => {
458
455
return false ;
459
456
} ) ;
460
457
}
0 commit comments