@@ -351,19 +351,17 @@ class ParseLiveQueryServer {
351351 if ( fromCache ) {
352352 return fromCache ;
353353 }
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 ;
367365 }
368366
369367 async _matchesCLP ( classLevelPermissions : ?any , object : any , client : any , requestId : number , op : string) : any {
@@ -379,10 +377,10 @@ class ParseLiveQueryServer {
379377 }
380378 try {
381379 await SchemaController . validatePermission ( classLevelPermissions , object . className , aclGroup , op ) ;
382- return Promise . resolve ( true ) ;
380+ return true ;
383381 } catch ( e ) {
384382 logger . verbose ( `Failed matching CLP for ${ object . id } ${ userId } ${ e } ` ) ;
385- return Promise . resolve ( false ) ;
383+ return false ;
386384 }
387385 // TODO: handle roles permissions
388386 // Object.keys(classLevelPermissions).forEach((key) => {
@@ -403,22 +401,22 @@ class ParseLiveQueryServer {
403401 && typeof query . objectId === 'string' ? 'get' : 'find' ;
404402 }
405403
406- async _matchesACL ( acl : any , client : any , requestId : number) : any {
404+ async _matchesACL ( acl : any , client : any , requestId : number) : Promise < boolean > {
407405 // Return true directly if ACL isn't present, ACL is public read, or client has master key
408406 if ( ! acl || acl . getPublicReadAccess ( ) || client . hasMasterKey ) {
409- return Promise . resolve ( true ) ;
407+ return true ;
410408 }
411409 // Check subscription sessionToken matches ACL first
412410 const subscriptionInfo = client . getSubscriptionInfo ( requestId ) ;
413411 if ( typeof subscriptionInfo === 'undefined' ) {
414- return Promise . resolve ( false ) ;
412+ return false ;
415413 }
416414
417415 // TODO: get auth there and de-duplicate code below to work with the same Auth obj.
418416 const { auth , userId } = await this . getAuthForSessionToken ( subscriptionInfo . sessionToken ) ;
419417 const isSubscriptionSessionTokenMatched = acl . getReadAccess ( userId ) ;
420418 if ( isSubscriptionSessionTokenMatched ) {
421- return Promise . resolve ( true ) ;
419+ return true ;
422420 }
423421
424422 // Check if the user has any roles that match the ACL
@@ -453,8 +451,7 @@ class ParseLiveQueryServer {
453451 } else {
454452 return isRoleMatched ;
455453 }
456- } ) . catch ( ( error ) => {
457- error ;
454+ } ) . catch ( ( ) => {
458455 return false ;
459456 } ) ;
460457 }
0 commit comments