diff --git a/src/routes/apps.js b/src/routes/apps.js index 5bd11f2d2..a51dd1ab9 100644 --- a/src/routes/apps.js +++ b/src/routes/apps.js @@ -3,6 +3,7 @@ exports = module.exports = { getApp: getApp, getApps: getApps, + getAllByUser: getAllByUser, getAppIcon: getAppIcon, installApp: installApp, configureApp: configureApp, @@ -82,8 +83,19 @@ function getApp(req, res, next) { function getApps(req, res, next) { assert.strictEqual(typeof req.user, 'object'); - var func = req.user.admin ? apps.getAll : apps.getAllByUser.bind(null, req.user); - func(function (error, allApps) { + apps.getAll(function (error, allApps) { + if (error) return next(new HttpError(500, error)); + + allApps = allApps.map(removeInternalAppFields); + + next(new HttpSuccess(200, { apps: allApps })); + }); +} + +function getAllByUser(req, res, next) { + assert.strictEqual(typeof req.user, 'object'); + + apps.getAllByUser(req.user, function (error, allApps) { if (error) return next(new HttpError(500, error)); allApps = allApps.map(removeInternalAppFields); diff --git a/src/server.js b/src/server.js index c59158d12..ffe1342e9 100644 --- a/src/server.js +++ b/src/server.js @@ -127,6 +127,7 @@ function initializeExpressSync() { router.get ('/api/v1/cloudron/eventlog', cloudronScope, routes.user.requireAdmin, routes.eventlog.get); // working off the user behind the provided token + router.get ('/api/v1/user/apps', profileScope, routes.apps.getAllByUser); router.get ('/api/v1/user/profile', profileScope, routes.profile.get); router.post('/api/v1/user/profile', profileScope, routes.profile.update); router.post('/api/v1/user/profile/password', profileScope, routes.user.verifyPassword, routes.profile.changePassword);