jxp 2.12.0 → 2.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/libs/security.js +7 -7
  2. package/package.json +1 -1
package/libs/security.js CHANGED
@@ -177,7 +177,7 @@ const refreshToken = async user_id => {
177
177
 
178
178
  const revokeToken = async user_id => {
179
179
  await Token.deleteOne({ user_id, provider });
180
- return true;
180
+ return;
181
181
  }
182
182
 
183
183
  const generateRefreshToken = async user_id => {
@@ -203,7 +203,7 @@ const ensureRefreshToken = async user_id => {
203
203
 
204
204
  const revokeRefreshToken = async user_id => {
205
205
  await RefreshToken.deleteMany({ user_id });
206
- return true;
206
+ return;
207
207
  }
208
208
 
209
209
  const refresh = async (req, res) => {
@@ -334,7 +334,7 @@ const check_perms = async (user, groups, model, method, item_id) => {
334
334
  //First check if "all" is able to do this. If so, let's get on with it.
335
335
  if (perms.all && perms.all.length) {
336
336
  if (perms.all.indexOf(method) !== -1) {
337
- return true;
337
+ return;
338
338
  }
339
339
  }
340
340
  //This isn't an 'all' situation, so let's bail if the user isn't logged in
@@ -345,24 +345,24 @@ const check_perms = async (user, groups, model, method, item_id) => {
345
345
  //Admin check
346
346
  if (user.admin && perms.admin && perms.admin.includes(method)) {
347
347
  // console.log("Matched permission 'admin':" + method);
348
- return true;
348
+ return;
349
349
  }
350
350
  //User check
351
351
  if (perms.user && perms.user.includes(method)) {
352
352
  // console.log("Matched permission 'user':" + method);
353
- return true;
353
+ return;
354
354
  }
355
355
  //Group check
356
356
  for (let group of groups) {
357
357
  if (perms[group] && perms[group].includes(method) ) {
358
358
  // console.log("Matched permission '" + group + "':" + method);
359
- return true;
359
+ return;
360
360
  }
361
361
  }
362
362
  //Owner check
363
363
  if (!item_id) throw (`Authorization failed - ${method}`);
364
364
  const item = await model.findById(item_id);
365
- if (item && item._owner_id && item._owner_id.toString() == user._id.toString() && (perms.owner && perms.owner.includes(method))) return true;
365
+ if (item && item._owner_id && item._owner_id.toString() == user._id.toString() && (perms.owner && perms.owner.includes(method))) return;
366
366
  throw ("Authorization failed");
367
367
  } catch (err) {
368
368
  if (err.code) throw err;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jxp",
3
3
  "description:": "An opinionated RESTful API library based on Mongoose and Restify. Make an API by just writing Mongoose models.",
4
- "version": "2.12.0",
4
+ "version": "2.12.1",
5
5
  "private": false,
6
6
  "main": "libs/jxp.js",
7
7
  "scripts": {