Skip to content

Commit f86acd7

Browse files
committed
4.3.0-hustle8
1 parent cc7aa21 commit f86acd7

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hustle/parse-server",
3-
"version": "4.3.0-hustle4",
3+
"version": "4.3.0-hustle8",
44
"description": "An express module providing a Parse-compatible API server",
55
"main": "lib/index.js",
66
"repository": {

src/Auth.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function Auth({
2929

3030
// Whether this auth could possibly modify the given user id.
3131
// It still could be forbidden via ACLs even if this returns true.
32-
Auth.prototype.isUnauthenticated = function() {
32+
Auth.prototype.isUnauthenticated = function () {
3333
if (this.isMaster) {
3434
return false;
3535
}
@@ -55,7 +55,7 @@ function nobody(config) {
5555
}
5656

5757
// Returns a promise that resolves to an Auth object
58-
const getAuthForSessionToken = async function({
58+
const getAuthForSessionToken = async function ({
5959
config,
6060
cacheController,
6161
sessionToken,
@@ -94,11 +94,13 @@ const getAuthForSessionToken = async function({
9494
);
9595
results = (await query.execute()).results;
9696
} 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());
102104
}
103105

104106
if (results.length !== 1 || !results[0]['user']) {
@@ -134,7 +136,7 @@ const getAuthForSessionToken = async function({
134136
});
135137
};
136138

137-
var getAuthForLegacySessionToken = function({
139+
var getAuthForLegacySessionToken = function ({
138140
config,
139141
sessionToken,
140142
installationId,
@@ -201,6 +203,7 @@ Auth.prototype._loadUserRolesForAccess = async function () {
201203
{},
202204
{
203205
pipeline: this._generateRoleGraphPipeline(),
206+
readPreference: 'SECONDARY_PREFERRED',
204207
}
205208
).execute();
206209

@@ -210,7 +213,7 @@ Auth.prototype._loadUserRolesForAccess = async function () {
210213
};
211214

212215
const roles = [...directRoles, ...childRoles];
213-
this.userRoles = roles.map((role) => `role:${role.name}`);
216+
this.userRoles = roles.map(role => `role:${role.name}`);
214217
this.fetchedRoles = true;
215218
this.rolePromise = null;
216219
this.cacheRoles();
@@ -307,7 +310,7 @@ Auth.prototype._generateRoleGraphPipeline = function () {
307310
];
308311
};
309312

310-
Auth.prototype.getRolesForUser = async function() {
313+
Auth.prototype.getRolesForUser = async function () {
311314
//Stack all Parse.Role
312315
const results = [];
313316
if (this.config) {
@@ -334,7 +337,7 @@ Auth.prototype.getRolesForUser = async function() {
334337
};
335338

336339
// Iterates through the role tree and compiles a user's roles
337-
Auth.prototype._loadRoles = async function() {
340+
Auth.prototype._loadRoles = async function () {
338341
if (this.cacheController) {
339342
const cachedRoles = await this.cacheController.role.get(this.user.id);
340343
if (cachedRoles != null) {
@@ -378,15 +381,15 @@ Auth.prototype._loadRoles = async function() {
378381
return this.userRoles;
379382
};
380383

381-
Auth.prototype.cacheRoles = function() {
384+
Auth.prototype.cacheRoles = function () {
382385
if (!this.cacheController) {
383386
return false;
384387
}
385388
this.cacheController.role.put(this.user.id, Array(...this.userRoles));
386389
return true;
387390
};
388391

389-
Auth.prototype.getRolesByIds = async function(ins) {
392+
Auth.prototype.getRolesByIds = async function (ins) {
390393
const results = [];
391394
// Build an OR query across all parentRoles
392395
if (!this.config) {
@@ -421,7 +424,7 @@ Auth.prototype.getRolesByIds = async function(ins) {
421424
};
422425

423426
// 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 (
425428
roleIDs,
426429
names = [],
427430
queriedRoles = {}
@@ -466,7 +469,7 @@ Auth.prototype._getAllRolesNamesForRoleIds = function(
466469
});
467470
};
468471

469-
const createSession = function(
472+
const createSession = function (
470473
config,
471474
{ userId, createdWith, installationId, additionalSessionData }
472475
) {

0 commit comments

Comments
 (0)