| … | … | @@ -55,19 +55,28 @@ export function registerRepoRoutes(router) { |
| 55 | 55 | async function handleListRepos(req, res, server) { |
| 56 | 56 | const { repos, linkedRepos } = server.repoData |
| 57 | 57 | try { |
| 58 | | const repoList = repos.map(repo => ({ |
| 59 | | name: repo.name, |
| 60 | | path: repo.path, |
| 61 | | commits: repo.commits || 0, |
| 62 | | branches: repo.branches || 0, |
| 63 | | lastCommit: repo.lastCommit || null, |
| 64 | | visibility: repo.visibility || 'public', |
| 65 | | owner: repo.owner || null, |
| 66 | | category: repo.category || null, |
| 67 | | namespace: repo.namespace || null, |
| 68 | | deploy: repo.deploy || null, |
| 69 | | linked: linkedRepos && linkedRepos.has(repo.name) ? true : undefined |
| 70 | | })) |
| 58 | // Check if request is from an admin (has valid auth) |
| 59 | const isAdmin = req.user && req.user.globalPermissions && req.user.globalPermissions.admin |
| 60 | |
| 61 | const repoList = repos |
| 62 | .filter(repo => { |
| 63 | // Private repos only visible to admins |
| 64 | if ((repo.visibility === 'private') && !isAdmin) return false |
| 65 | return true |
| 66 | }) |
| 67 | .map(repo => ({ |
| 68 | name: repo.name, |
| 69 | path: repo.path, |
| 70 | commits: repo.commits || 0, |
| 71 | branches: repo.branches || 0, |
| 72 | lastCommit: repo.lastCommit || null, |
| 73 | visibility: repo.visibility || 'public', |
| 74 | owner: repo.owner || null, |
| 75 | category: repo.category || null, |
| 76 | namespace: repo.namespace || null, |
| 77 | deploy: repo.deploy || null, |
| 78 | linked: linkedRepos && linkedRepos.has(repo.name) ? true : undefined |
| 79 | })) |
| 71 | 80 | |
| 72 | 81 | json(res, repoList) |
| 73 | 82 | } catch (err) { |