forked from conwetlab/Accounting-Proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli-unbindAdmin
executable file
·38 lines (28 loc) · 1.02 KB
/
cli-unbindAdmin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env node
// Unbinds the specified administrator from the specified service identified by its public path.
var program = require('commander'),
config = require('./config'),
logger = require('./log')
util = require('./util');
var db = require(config.database.type);
program
.description('Deletes the specified administrator for the specified service by its public path')
.parse(process.argv);
if (program.args.length !== 2) {
logger.error('Invalid number of arguments. Usage: ./cli unbindAdmin <userId> <publicPath>');
console.log(program.help());
} else {
var userId = program.args[0];
var publicPath = program.args[1];
if (!util.pathRegExp.test(publicPath)) {
logger.error(util.invalidPathError);
} else {
db.unbindAdmin(userId, publicPath, function(err) {
if (err) {
logger.error(err);
} else {
logger.info('Administrator ' + userId + ' delete from service ' + publicPath);
}
});
}
}