mirror of
https://git.proxmox.com/git/pve-access-control
synced 2025-08-05 05:46:39 +00:00
make read_password a CLIHandler class method
And use new run_cli_handler() method.
This commit is contained in:
parent
90399ca489
commit
98007830ee
@ -21,6 +21,18 @@ use PVE::CLIHandler;
|
||||
|
||||
use base qw(PVE::CLIHandler);
|
||||
|
||||
sub read_password {
|
||||
# return $ENV{PVE_PW_TICKET} if defined($ENV{PVE_PW_TICKET});
|
||||
|
||||
my $term = new Term::ReadLine ('pveum');
|
||||
my $attribs = $term->Attribs;
|
||||
$attribs->{redisplay_function} = $attribs->{shadow_redisplay};
|
||||
my $input = $term->readline('Enter new password: ');
|
||||
my $conf = $term->readline('Retype new password: ');
|
||||
die "Passwords do not match.\n" if ($input ne $conf);
|
||||
return $input;
|
||||
}
|
||||
|
||||
our $cmddef = {
|
||||
ticket => [ 'PVE::API2::AccessControl', 'create_ticket', ['username'], undef,
|
||||
sub {
|
||||
|
15
pveum
15
pveum
@ -5,22 +5,9 @@ use warnings;
|
||||
|
||||
use PVE::CLI::pveum;
|
||||
|
||||
my $read_password = sub {
|
||||
|
||||
# return $ENV{PVE_PW_TICKET} if defined($ENV{PVE_PW_TICKET});
|
||||
|
||||
my $term = new Term::ReadLine ('pveum');
|
||||
my $attribs = $term->Attribs;
|
||||
$attribs->{redisplay_function} = $attribs->{shadow_redisplay};
|
||||
my $input = $term->readline('Enter new password: ');
|
||||
my $conf = $term->readline('Retype new password: ');
|
||||
die "Passwords do not match.\n" if ($input ne $conf);
|
||||
return $input;
|
||||
};
|
||||
|
||||
my $prepare = sub {
|
||||
# autmatically generate the private key if it does not already exists
|
||||
PVE::Cluster::gen_auth_key();
|
||||
};
|
||||
|
||||
PVE::CLI::pveum->run_cli($read_password, undef, $prepare);
|
||||
PVE::CLI::pveum->run_cli_handler(prepare => $prepare);
|
||||
|
Loading…
Reference in New Issue
Block a user