Skip to content

Commit

Permalink
fix(User): always return default access apps
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeaturner committed Feb 12, 2025
1 parent 41d0fc0 commit c00763c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions server/controllers/UserController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export class UserController {
const isLibrary = curr.get('app_type') === 'library';
const isUnsupported = curr.get('supports_cas') === false;
if (
(isLibrary || isUnsupported || userApps.find((a) => a.get('id') === curr.get('id')))
(isLibrary || isUnsupported || curr.default_access === 'all' || userApps.find((a) => a.get('id') === curr.get('id')))
&& !acc[curr.get('id')]
) {
acc[curr.get('id')] = curr.get();
Expand Down Expand Up @@ -497,6 +497,10 @@ export class UserController {
criteria.push({ app_type: type });
}

const defaultAccessApps = await Application.findAll({
where: { default_access: 'all' },
});

const foundApps = await Application.findAll({
where: criteria.length > 1 ? { [Op.and]: criteria } : criteria[0],
include: [
Expand All @@ -509,9 +513,16 @@ export class UserController {
],
});

const appIds = new Set<number>();
const uniqueApps = [...defaultAccessApps, ...foundApps].map((a) => a.get()).filter((a) => {
if (appIds.has(a.id)) return false;
appIds.add(a.id);
return true;
});

return res.send({
data: {
applications: foundApps.map((a) => a.get()) || [],
applications: uniqueApps,
},
});
}
Expand Down

0 comments on commit c00763c

Please sign in to comment.