@@ -29,7 +29,7 @@ function Auth({
29
29
30
30
// Whether this auth could possibly modify the given user id.
31
31
// It still could be forbidden via ACLs even if this returns true.
32
- Auth . prototype . isUnauthenticated = function ( ) {
32
+ Auth . prototype . isUnauthenticated = function ( ) {
33
33
if ( this . isMaster ) {
34
34
return false ;
35
35
}
@@ -55,7 +55,7 @@ function nobody(config) {
55
55
}
56
56
57
57
// Returns a promise that resolves to an Auth object
58
- const getAuthForSessionToken = async function ( {
58
+ const getAuthForSessionToken = async function ( {
59
59
config,
60
60
cacheController,
61
61
sessionToken,
@@ -94,11 +94,13 @@ const getAuthForSessionToken = async function({
94
94
) ;
95
95
results = ( await query . execute ( ) ) . results ;
96
96
} else {
97
- results = ( await new Parse . Query ( Parse . Session )
98
- . limit ( 1 )
99
- . include ( 'user' )
100
- . equalTo ( 'sessionToken' , sessionToken )
101
- . find ( { useMasterKey : true } ) ) . map ( obj => obj . toJSON ( ) ) ;
97
+ results = (
98
+ await new Parse . Query ( Parse . Session )
99
+ . limit ( 1 )
100
+ . include ( 'user' )
101
+ . equalTo ( 'sessionToken' , sessionToken )
102
+ . find ( { useMasterKey : true } )
103
+ ) . map ( obj => obj . toJSON ( ) ) ;
102
104
}
103
105
104
106
if ( results . length !== 1 || ! results [ 0 ] [ 'user' ] ) {
@@ -134,7 +136,7 @@ const getAuthForSessionToken = async function({
134
136
} ) ;
135
137
} ;
136
138
137
- var getAuthForLegacySessionToken = function ( {
139
+ var getAuthForLegacySessionToken = function ( {
138
140
config,
139
141
sessionToken,
140
142
installationId,
@@ -201,6 +203,7 @@ Auth.prototype._loadUserRolesForAccess = async function () {
201
203
{ } ,
202
204
{
203
205
pipeline : this . _generateRoleGraphPipeline ( ) ,
206
+ readPreference : 'SECONDARY_PREFERRED' ,
204
207
}
205
208
) . execute ( ) ;
206
209
@@ -210,7 +213,7 @@ Auth.prototype._loadUserRolesForAccess = async function () {
210
213
} ;
211
214
212
215
const roles = [ ...directRoles , ...childRoles ] ;
213
- this . userRoles = roles . map ( ( role ) => `role:${ role . name } ` ) ;
216
+ this . userRoles = roles . map ( role => `role:${ role . name } ` ) ;
214
217
this . fetchedRoles = true ;
215
218
this . rolePromise = null ;
216
219
this . cacheRoles ( ) ;
@@ -307,7 +310,7 @@ Auth.prototype._generateRoleGraphPipeline = function () {
307
310
] ;
308
311
} ;
309
312
310
- Auth . prototype . getRolesForUser = async function ( ) {
313
+ Auth . prototype . getRolesForUser = async function ( ) {
311
314
//Stack all Parse.Role
312
315
const results = [ ] ;
313
316
if ( this . config ) {
@@ -334,7 +337,7 @@ Auth.prototype.getRolesForUser = async function() {
334
337
} ;
335
338
336
339
// Iterates through the role tree and compiles a user's roles
337
- Auth . prototype . _loadRoles = async function ( ) {
340
+ Auth . prototype . _loadRoles = async function ( ) {
338
341
if ( this . cacheController ) {
339
342
const cachedRoles = await this . cacheController . role . get ( this . user . id ) ;
340
343
if ( cachedRoles != null ) {
@@ -378,15 +381,15 @@ Auth.prototype._loadRoles = async function() {
378
381
return this . userRoles ;
379
382
} ;
380
383
381
- Auth . prototype . cacheRoles = function ( ) {
384
+ Auth . prototype . cacheRoles = function ( ) {
382
385
if ( ! this . cacheController ) {
383
386
return false ;
384
387
}
385
388
this . cacheController . role . put ( this . user . id , Array ( ...this . userRoles ) ) ;
386
389
return true ;
387
390
} ;
388
391
389
- Auth . prototype . getRolesByIds = async function ( ins ) {
392
+ Auth . prototype . getRolesByIds = async function ( ins ) {
390
393
const results = [ ] ;
391
394
// Build an OR query across all parentRoles
392
395
if ( ! this . config ) {
@@ -421,7 +424,7 @@ Auth.prototype.getRolesByIds = async function(ins) {
421
424
} ;
422
425
423
426
// Given a list of roleIds, find all the parent roles, returns a promise with all names
424
- Auth . prototype . _getAllRolesNamesForRoleIds = function (
427
+ Auth . prototype . _getAllRolesNamesForRoleIds = function (
425
428
roleIDs ,
426
429
names = [ ] ,
427
430
queriedRoles = { }
@@ -466,7 +469,7 @@ Auth.prototype._getAllRolesNamesForRoleIds = function(
466
469
} ) ;
467
470
} ;
468
471
469
- const createSession = function (
472
+ const createSession = function (
470
473
config ,
471
474
{ userId, createdWith, installationId, additionalSessionData }
472
475
) {
0 commit comments