]> git.proxmox.com Git - pve-access-control.git/blobdiff - PVE/API2/AccessControl.pm
rename user_enabled to check_user_enabled
[pve-access-control.git] / PVE / API2 / AccessControl.pm
index f06a244d6b8783ec84fde00919163f985b43baab..5967c50ea30200caf6a2fb042b03edf176348d27 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 
 use PVE::SafeSyslog;
 use PVE::RPCEnvironment;
-use PVE::Cluster;
+use PVE::Cluster qw(cfs_read_file);
 use PVE::RESTHandler;
 use PVE::AccessControl;
 use PVE::JSONSchema qw(get_standard_option);
@@ -140,6 +140,9 @@ __PACKAGE__->register_method ({
        my $token;
        eval {
 
+           # test if user exists and is enabled
+           $rpcenv->check_user_enabled($username);
+
            if ($param->{path} && $param->{privs}) {
                my $privs = [ PVE::Tools::split_list($param->{privs}) ];
                my $path = PVE::AccessControl::normalize_path($param->{path});
@@ -154,9 +157,6 @@ __PACKAGE__->register_method ({
                # got valid ticket
                # Note: root@pam can create tickets for other users
                
-               # test if user exists and is enabled
-               my $usercfg = cfs_read_file('user.cfg');
-               die "no such user ('$username')\n" if !user_enabled($usercfg, $username);
            } else {
                $username = PVE::AccessControl::authenticate_user($username, $param->{password});
            }