Bläddra i källkod

setting right for multiple users

Benoit Sida 4 år sedan
förälder
incheckning
7eef4fdbb0
2 ändrade filer med 26 tillägg och 41 borttagningar
  1. 22
    14
      blih.js
  2. 4
    27
      package.json

+ 22
- 14
blih.js Visa fil

@@ -59,7 +59,7 @@ class Blih {
59 59
 	}
60 60
 
61 61
 	token_calc() {
62
-		return crypto.createHash('sha512').update(prompt(`${this._user}'s password: `, {echo: '*'}) || process.exit(1)).digest('hex');
62
+		return crypto.createHash('sha512').update(prompt(`${this._user}'s password: `, {echo: ''}) || process.exit(1)).digest('hex');
63 63
 	}
64 64
 }
65 65
 
@@ -81,15 +81,15 @@ class Repository extends Subcommand {
81 81
 		Usage: ${process.argv[1]} [options] repository command ...
82 82
 		
83 83
 		Commands:
84
-		    create repo\t\tCreate a repository named "repo"
85
-		    info repo\t\t\tGet the repository metadata
86
-		    getacl repo\t\tGet the acls set for the repository
87
-		    list\t\t\tList the repositories created
88
-		    setacl repo user [acl]\tSet (or remove) an acl for "user" on "repo"
89
-		    \t\t\t\tACL format:
90
-		    \t\t\t\t\tr for read
91
-		    \t\t\t\t\tw for write
92
-		    \t\t\t\t\ta for admin
84
+		    create repo\t\t\tCreate a repository named "repo"
85
+		    info repo\t\t\t\tGet the repository metadata
86
+		    getacl repo\t\t\tGet the acls set for the repository
87
+		    list\t\t\t\tList the repositories created
88
+		    setacl repo user [user...] [acl]\tSet (or remove) an acl for each "user" on "repo"
89
+		    \t\t\t\t\tACL format:
90
+		    \t\t\t\t\t\tr for read
91
+		    \t\t\t\t\t\tw for write
92
+		    \t\t\t\t\t\ta for admin
93 93
 		`;
94 94
 		this.usage_message = '\n  ' + this.usage_message.substr(3).replace(/\n\t\t/g, '\n  ');
95 95
 	}
@@ -138,10 +138,18 @@ class Repository extends Subcommand {
138 138
 		if (params.length < 2)
139 139
 			return this.usage();
140 140
 		const blih = new Blih(this.options);
141
-		blih.request({ path: `/repository/${params[0]}/acls`, method:'POST', data: {
142
-			user: params[1],
143
-			acl: params[2] || ''
144
-		}});
141
+		const repo = params.shift();
142
+		const rights = params.pop();
143
+		var users = params;
144
+		for (let user of users) {
145
+			blih.request({ 
146
+				path: `/repository/${repo}/acls`,
147
+				method:'POST', data: {
148
+					user: user,
149
+					acl: rights || ''
150
+				}
151
+			});
152
+		}
145 153
 	}
146 154
 
147 155
 	getacl(params) {

+ 4
- 27
package.json Visa fil

@@ -2,16 +2,7 @@
2 2
   "name": "glih",
3 3
   "version": "1.0.0",
4 4
   "description": "javascript version of epitech's blih utility",
5
-  "main": "main.js",
6
-  "scripts": {
7
-    "glih": "blih.js",
8
-    "watch": "webpack --progress --watch",
9
-    "build": "webpack --optimize-minimize -p",
10
-    "run": "electron ."
11
-  },
12
-  "bin": {
13
-    "glih": "blih.js"
14
-  },
5
+  "bin": "./blih.js",
15 6
   "repository": {
16 7
     "type": "git",
17 8
     "url": "ssh://git@git.coldiary.eu:10022/coldiary/Glih.git"
@@ -20,23 +11,9 @@
20 11
   "license": "ISC",
21 12
   "dependencies": {
22 13
     "commander": "^2.9.0",
23
-    "json-stable-stringify": "^1.0.1",
24
-    "material-ui": "^0.16.0",
25 14
     "prompt-sync": "^4.1.4",
26
-    "react": "^15.3.2",
27
-    "react-dom": "^15.3.2",
28
-    "react-tap-event-plugin": "^1.0.0",
29
-    "request": "^2.75.0",
30
-    "utf8": "^2.1.1"
31
-  },
32
-  "devDependencies": {
33
-    "babel-preset-es2015": "^6.16.0",
34
-    "babel-preset-react": "^6.16.0"
35
-  },
36
-  "babel": {
37
-    "presets": [
38
-      "es2015",
39
-      "react"
40
-    ]
15
+    "utf8": "^2.1.1",
16
+    "json-stable-stringify": "^1.0.1",
17
+    "request": "^2.75.0"
41 18
   }
42 19
 }