Skip to content

Commit

Permalink
Merge pull request #85 from CloudEcosystemDev/feat/add-user-filter-te…
Browse files Browse the repository at this point in the history
…nant

Feat/add user filter tenant
  • Loading branch information
jorgerusso committed Oct 2, 2023
2 parents 4835a24 + ae911b0 commit 20cda60
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion services/iam/src/routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ router.post('/', auth.hasTenantPermissions([PERMISSIONS['tenant.account.create']
/**
* Get all Users
*/
router.get('/', auth.isAdmin, async (req, res, next) => {
router.get('/', auth.isLoggedIn, async (req, res, next) => {
try {
const filter = {};
if (req.query.userId) {
Expand All @@ -112,6 +112,10 @@ router.get('/', auth.isAdmin, async (req, res, next) => {
$in: filterUsernames,
};
}
// we assure that a user can only fetch users from their tenant
if (!req.user.isAdmin) {
filter.tenant = req.user.tenant;
}
const doc = await AccountDAO.find(filter);

if (req.query.meta) {
Expand Down

0 comments on commit 20cda60

Please sign in to comment.