Created
May 26, 2016 18:34
-
-
Save radamant/b3742a0b45a0a7caca04fc10cf04f9d3 to your computer and use it in GitHub Desktop.
Flowdock User Audit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Client = require('node-rest-client').Client; | |
var apiToken = process.argv[2]; | |
var auth = { user: apiToken, password: ""}; | |
var client = new Client(auth); | |
const ALL_FLOWS_URL = "https://api.flowdock.com/flows/all?users=1"; | |
function getResource(url, success) { | |
client.get(url, function(data, response){ | |
if(response.statusCode != 200){ | |
console.log("Error", code, data); | |
return; | |
} | |
success(data) | |
}); | |
} | |
function mapFlows(mapFunction) { | |
return function(flows){ | |
for(var i = 0; i < flows.length; i++) { | |
var flow = flows[i]; | |
mapFunction(flow); | |
} | |
} | |
} | |
function reportFlowUsers(flow) { | |
console.log(flow.name, "(" + flow.organization.name + ")"); | |
console.log("-------------------"); | |
var users = flow.users; | |
for(var i = 0; i < users.length; i++){ | |
var user = users[i]; | |
var line = user.nick + ", " + user.name; | |
if(user.disabled) { | |
line += " (DISABLED)"; | |
} | |
if(user.flow_admin) { | |
line += " (ADMIN)"; | |
} | |
console.log(line); | |
} | |
console.log("\n"); | |
} | |
getResource(ALL_FLOWS_URL, mapFlows(reportFlowUsers)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "flowdock-permissions-audit", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "Adam Pearson", | |
"license": "ISC", | |
"dependencies": { | |
"node-rest-client": "^1.8.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment