Skip to content

Commit

Permalink
fix: reverse uid checks
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Jul 29, 2020
1 parent 303bffd commit 7331fae
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/groups/membership.js
Expand Up @@ -4,7 +4,6 @@ const _ = require('lodash');

const db = require('../database');
const user = require('../user');

const cache = require('../cache');

module.exports = function (Groups) {
Expand All @@ -25,7 +24,7 @@ module.exports = function (Groups) {
};

Groups.isMember = async function (uid, groupName) {
if (!uid || parseInt(uid, 10) <= 0 || !groupName) {
if (!uid || !(parseInt(uid, 10) > 0) || !groupName) {
return false;
}

Expand Down Expand Up @@ -66,7 +65,7 @@ module.exports = function (Groups) {
};

Groups.isMemberOfGroups = async function (uid, groups) {
if (!uid || parseInt(uid, 10) <= 0 || !groups.length) {
if (!uid || !(parseInt(uid, 10) > 0) || !groups.length) {
return groups.map(groupName => groupName === 'guests');
}
const cachedData = {};
Expand Down

0 comments on commit 7331fae

Please sign in to comment.