[pve-devel] r6230 - in pve-access-control/trunk: . PVE/API2

svn-commits at proxmox.com svn-commits at proxmox.com
Tue Jul 5 08:22:46 CEST 2011


Author: dietmar
Date: 2011-07-05 08:22:46 +0200 (Tue, 05 Jul 2011)
New Revision: 6230

Modified:
   pve-access-control/trunk/ChangeLog
   pve-access-control/trunk/PVE/API2/User.pm
Log:
use -enable instead of -lock/-unlock


Modified: pve-access-control/trunk/ChangeLog
===================================================================
--- pve-access-control/trunk/ChangeLog	2011-07-04 11:59:19 UTC (rev 6229)
+++ pve-access-control/trunk/ChangeLog	2011-07-05 06:22:46 UTC (rev 6230)
@@ -1,3 +1,10 @@
+2011-07-05  Proxmox Support Team  <support at proxmox.com>
+
+	* PVE/API2/User.pm (create_user): add -enable parameter
+
+	* PVE/API2/User.pm (update_user): use -enable instead of
+	-lock/-unlock
+
 2011-06-27  Proxmox Support Team  <support at proxmox.com>
 
 	* PVE/AccessControl.pm (normalize_path): allow '-' in path

Modified: pve-access-control/trunk/PVE/API2/User.pm
===================================================================
--- pve-access-control/trunk/PVE/API2/User.pm	2011-07-04 11:59:19 UTC (rev 6229)
+++ pve-access-control/trunk/PVE/API2/User.pm	2011-07-05 06:22:46 UTC (rev 6230)
@@ -88,8 +88,14 @@
 		description => "Account expiration date (seconds since epoch). '0' means no expiration date.",
 		type => 'integer', 
 		minimum => 0,
-		optional => 1 
+		optional => 1,
 	    },
+	    enable => {
+		description => "Enable the account (default). You can set this to '0' to disable the accout",
+		type => 'boolean',
+		optional => 1,
+		default => 1,
+	    },
 	},
     },
     returns => { type => 'null' },
@@ -109,7 +115,8 @@
 		PVE::AccessControl::domain_set_password($realm, $ruid, $param->{password})
 		    if $param->{password};
 
-		$usercfg->{users}->{$username} = { enabled => 1 };
+		my $enabled = defined($param->{enable}) ? $param->{enable} : 1;
+		$usercfg->{users}->{$username} = { enabled => $enabled };
 		$usercfg->{users}->{$username}->{expire} = $param->{expire} if $param->{expire};
 
 		if ($param->{groups}) {
@@ -188,8 +195,11 @@
 		optional => 1,
 		requires => 'groups',
 	    },
-	    lock => { type => 'boolean', optional => 1 },
-	    unlock => { type => 'boolean', optional => 1 },
+	    enable => {
+		description => "Enable/disable the account.",
+		type => 'boolean',
+		optional => 1,
+	    },
 	    firstname => { type => 'string', optional => 1 },
 	    lastname => { type => 'string', optional => 1 },
 	    email => { type => 'string', optional => 1, format => 'email-opt' },
@@ -209,9 +219,6 @@
 	PVE::AccessControl::lock_user_config(
 	    sub {
 
-		die "conflicting parameters unlock/lock\n" 
-		    if $param->{unlock} && $param->{lock};
-
 		my ($username, $ruid, $realm) = 
 		    PVE::AccessControl::verify_username($param->{userid});
 	
@@ -223,10 +230,8 @@
 		PVE::AccessControl::domain_set_password($realm, $ruid, $param->{password})
 		    if $param->{password};
 
-		$usercfg->{users}->{$username}->{enabled} = 1 if $param->{unlock};
+		$usercfg->{users}->{$username}->{enabled} = $param->{enable} if defined($param->{enable});
 
-		$usercfg->{users}->{$username}->{enabled} = 0 if $param->{lock};
-
 		$usercfg->{users}->{$username}->{expire} = $param->{expire} if defined($param->{expire});
 
 		PVE::AccessControl::delete_user_group($username, $usercfg) 




More information about the pve-devel mailing list