Add 'nopassword' parameter
Benjamin Renard

Benjamin Renard commited on 2014-11-27 14:58:14
Showing 3 changed files, with 16 additions and 2 deletions.

... ...
@@ -6,7 +6,8 @@ ViewGit : A form permit to give
6 6
 
7 7
 * repository name
8 8
 * repository description
9
-* a password witch protect this feature
9
+* a password witch protect this feature (except when nopassword option is set
10
+  to True)
10 11
 
11 12
 The repository name will be validated : it must contain only letter, number,
12 13
 "_" or "-" caracter.
... ...
@@ -17,6 +18,9 @@ description file of the repository.
17 18
 The given password will be compare with $conf['addrepo']['password'] value.
18 19
 If password is ommit in the configuration, the creation will be refused.
19 20
 
21
+If you want to completely disable password check, you have to set
22
+$conf['addrepo']['nopassword'] to True.
23
+
20 24
 After create a new repository, if you go on the repository page, you will have
21 25
 a message that explain you how to push your first commits. This message could
22 26
 be change by editing template file summary.php. This message is displayed only
... ...
@@ -38,5 +42,6 @@ Install
38 42
 $conf['addrepo'] = array(
39 43
         'root_path' => '/full/path/to/your/repos',
40 44
         'password' => 'secret',
45
+        'nopassword' => True|False,
41 46
         'url_format' => 'git@git.example.com:public_git/%s'
42 47
 );
... ...
@@ -16,7 +16,7 @@ class AddRepoPlugin extends VGPlugin
16 16
 		if ($action === 'addrepo') {
17 17
 			global $page;
18 18
 			global $conf;
19
-			if (isset($_POST['repo_name']) && isset($_POST['repo_desc']) && isset($_POST['repo_pwd'])) {
19
+			if (isset($_POST['repo_name']) && isset($_POST['repo_desc'])) {
20 20
 				$create=True;
21 21
 				$name=rtrim($_POST['repo_name']);
22 22
 				if (!$this -> validate_repo_name($name)) {
... ...
@@ -29,6 +29,7 @@ class AddRepoPlugin extends VGPlugin
29 29
 					$create=False;
30 30
 				}
31 31
 
32
+				if (!isset($conf['addrepo']['nopassword']) || ($conf['addrepo']['nopassword']===False)) {
32 33
 					if (!isset($conf['addrepo']['password']) || empty($conf['addrepo']['password'])) {
33 34
 						$this -> add_display_message('Password not defined in configuration. Creation disable.',True);
34 35
 						$create=False;
... ...
@@ -40,6 +41,7 @@ class AddRepoPlugin extends VGPlugin
40 41
 							$create=False;
41 42
 						}
42 43
 					}
44
+				}
43 45
 
44 46
 				if ($create && $this -> create_repo($name,$desc)) {
45 47
 					$this -> add_display_message("Repository $name successfully created !<br>To access to your new repository, click <a href='?a=summary&p=$name'>here</a>.");
... ...
@@ -18,8 +18,15 @@ if (isset($page['addrepo']['msg'])) {
18 18
 	<dd><input type='text' name='repo_name' class='addrepo' value="<?php echo (isset($page['addrepo']['values']['name'])?$page['addrepo']['values']['name']:''); ?>"/></dd>
19 19
 	<dt>Description</dt>
20 20
 	<dd><input type='text' name='repo_desc' class='addrepo' value="<?php echo (isset($page['addrepo']['values']['desc'])?$page['addrepo']['values']['desc']:''); ?>"/></dd>
21
+	<?php
22
+	global $conf;
23
+	if (!isset($conf['addrepo']['nopassword']) || ($conf['addrepo']['nopassword']===False)) {
24
+		echo"
21 25
 		<dt>Password</dt>
22 26
 		<dd><input type='password' name='repo_pwd' class='addrepo'/></dd>
27
+		";
28
+	}
29
+	?>
23 30
 </dl>
24 31
 <input type='submit' value='Create' id='addrepo_submit'/>
25 32
 </form>
26 33