]> git.proxmox.com Git - pve-access-control.git/blobdiff - PVE/API2/User.pm
Remove unused Dumper uses
[pve-access-control.git] / PVE / API2 / User.pm
index 139e3b6254359499f001e24b274cdfc9b8174716..602e3f030ba4bc990adf7717e659f1007cf1b7f5 100644 (file)
@@ -10,8 +10,6 @@ use PVE::JSONSchema qw(get_standard_option);
 
 use PVE::SafeSyslog;
 
-use Data::Dumper; # fixme: remove
-
 use PVE::RESTHandler;
 
 use base qw(PVE::RESTHandler);
@@ -21,7 +19,7 @@ my $extract_user_data = sub {
 
     my $res = {};
 
-    foreach my $prop (qw(enable expire firstname lastname email comment)) {
+    foreach my $prop (qw(enable expire firstname lastname email comment keys)) {
        $res->{$prop} = $data->{$prop} if defined($data->{$prop});
     }
 
@@ -119,11 +117,20 @@ __PACKAGE__->register_method ({
                minLength => 5, 
                maxLength => 64 
            },
-           groups => { type => 'string', optional => 1, format => 'pve-groupid-list'},
+           groups => {
+               type => 'string', format => 'pve-groupid-list',
+               optional => 1,
+               completion => \&PVE::AccessControl::complete_group,
+           },
            firstname => { type => 'string', optional => 1 },
            lastname => { type => 'string', optional => 1 },
            email => { type => 'string', optional => 1, format => 'email-opt' },
            comment => { type => 'string', optional => 1 },
+           keys => {
+               description => "Keys for two factor auth (yubico).",
+               type => 'string', 
+               optional => 1,
+           },
            expire => { 
                description => "Account expiration date (seconds since epoch). '0' means no expiration date.",
                type => 'integer', 
@@ -173,6 +180,7 @@ __PACKAGE__->register_method ({
                $usercfg->{users}->{$username}->{lastname} = $param->{lastname} if $param->{lastname};
                $usercfg->{users}->{$username}->{email} = $param->{email} if $param->{email};
                $usercfg->{users}->{$username}->{comment} = $param->{comment} if $param->{comment};
+               $usercfg->{users}->{$username}->{keys} = $param->{keys} if $param->{keys};
 
                cfs_write_file("user.cfg", $usercfg);
            }, "create user failed");
@@ -203,6 +211,7 @@ __PACKAGE__->register_method ({
            lastname => { type => 'string', optional => 1 },
            email => { type => 'string', optional => 1 },
            comment => { type => 'string', optional => 1 },    
+           keys => { type => 'string', optional => 1 },    
            groups => { type => 'array' },
        }
     },
@@ -231,8 +240,14 @@ __PACKAGE__->register_method ({
     parameters => {
        additionalProperties => 0,
        properties => {
-           userid => get_standard_option('userid'),
-           groups => { type => 'string', optional => 1,  format => 'pve-groupid-list'  },
+           userid => get_standard_option('userid', {
+               completion => \&PVE::AccessControl::complete_username,
+           }),
+           groups => {
+               type => 'string', format => 'pve-groupid-list',
+               optional => 1,
+               completion => \&PVE::AccessControl::complete_group,
+           },
            append => { 
                type => 'boolean', 
                optional => 1,
@@ -247,6 +262,11 @@ __PACKAGE__->register_method ({
            lastname => { type => 'string', optional => 1 },
            email => { type => 'string', optional => 1, format => 'email-opt' },
            comment => { type => 'string', optional => 1 },
+           keys => {
+               description => "Keys for two factor auth (yubico).",
+               type => 'string', 
+               optional => 1,
+           },
            expire => { 
                description => "Account expiration date (seconds since epoch). '0' means no expiration date.",
                type => 'integer', 
@@ -290,6 +310,7 @@ __PACKAGE__->register_method ({
                $usercfg->{users}->{$username}->{lastname} = $param->{lastname} if defined($param->{lastname});
                $usercfg->{users}->{$username}->{email} = $param->{email} if defined($param->{email});
                $usercfg->{users}->{$username}->{comment} = $param->{comment} if defined($param->{comment});
+               $usercfg->{users}->{$username}->{keys} = $param->{keys} if defined($param->{keys});
 
                cfs_write_file("user.cfg", $usercfg);
            }, "update user failed");
@@ -312,7 +333,9 @@ __PACKAGE__->register_method ({
     parameters => {
        additionalProperties => 0,
        properties => {
-           userid => get_standard_option('userid'),
+           userid => get_standard_option('userid', {
+               completion => \&PVE::AccessControl::complete_username,
+           }),
        }
     },
     returns => { type => 'null' },