mirror of
https://github.com/aljazceru/gitpear.git
synced 2025-12-17 06:04:25 +01:00
13
src/acl.js
13
src/acl.js
@@ -2,6 +2,9 @@ const home = require('./home')
|
||||
const fs = require('fs')
|
||||
|
||||
const ROLES = {
|
||||
owner: {
|
||||
description: 'Read and write to all branches, and ACL management',
|
||||
},
|
||||
admin: {
|
||||
description: 'Read and write to all branches',
|
||||
},
|
||||
@@ -23,9 +26,16 @@ function getUserRole (repoName, user) {
|
||||
return acl.ACL[user]
|
||||
}
|
||||
|
||||
function getOwners (repoName) {
|
||||
const acl = getACL(repoName)
|
||||
return Object.keys(acl.ACL).filter(user => acl.ACL[user] === 'owner')
|
||||
}
|
||||
|
||||
function getAdmins (repoName) {
|
||||
const acl = getACL(repoName)
|
||||
return Object.keys(acl.ACL).filter(user => acl.ACL[user] === 'admin')
|
||||
const admins = Object.keys(acl.ACL).filter(user => acl.ACL[user] === 'admin')
|
||||
const owners = getOwners(repoName)
|
||||
return [...admins, ...owners].filter((user, i, arr) => arr.indexOf(user) === i)
|
||||
}
|
||||
|
||||
function getContributors (repoName) {
|
||||
@@ -113,6 +123,7 @@ module.exports = {
|
||||
getACL,
|
||||
addProtectedBranch,
|
||||
removeProtectedBranch,
|
||||
getOwners,
|
||||
getAdmins,
|
||||
getContributors,
|
||||
getViewers,
|
||||
|
||||
Reference in New Issue
Block a user