[pmg-devel] [PATCH api 2/4] support forced account deactivation
Thomas Lamprecht
t.lamprecht at proxmox.com
Wed Mar 17 11:33:57 CET 2021
On 17.03.21 11:02, Wolfgang Bumiller wrote:
> Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
> ---
> src/PMG/API2/ACME.pm | 27 ++++++++++++++++++++++-----
> 1 file changed, 22 insertions(+), 5 deletions(-)
>
applied, thanks - squashed one change into it though.
> diff --git a/src/PMG/API2/ACME.pm b/src/PMG/API2/ACME.pm
> index 60b5986..d6dbf2f 100644
> --- a/src/PMG/API2/ACME.pm
> +++ b/src/PMG/API2/ACME.pm
> @@ -173,7 +173,7 @@ __PACKAGE__->register_method ({
> }});
>
> my $update_account = sub {
> - my ($param, $msg, %info) = @_;
> + my ($param, $msg, $force_deactivate, %info) = @_;
>
> my ($account_name, $account_file) = extract_account_name($param);
>
> @@ -190,7 +190,15 @@ my $update_account = sub {
> if ! -e $account_file;
>
> my $acme = PMG::RS::Acme->load($account_file);
> - $acme->update_account(\%info);
> + eval {
> + $acme->update_account(\%info);
> + };
> + my $err = $@;
> + if ($force_deactivate) {
> + warn $err if $err;
> + } else {
> + die $2;
fixed up above typo and logic
> + }
> if ($info{status} && $info{status} eq 'deactivated') {
> my $deactivated_name;
> for my $i (0..100) {
> @@ -239,9 +247,9 @@ __PACKAGE__->register_method ({
>
> my $contact = $account_contact_from_param->($param);
> if (scalar @$contact) {
> - return $update_account->($param, 'update', contact => $contact);
> + return $update_account->($param, 'update', 0, contact => $contact);
> } else {
> - return $update_account->($param, 'refresh');
> + return $update_account->($param, 'refresh', 0);
> }
> }});
>
> @@ -311,6 +319,13 @@ __PACKAGE__->register_method ({
> additionalProperties => 0,
> properties => {
> name => get_standard_option('pmg-acme-account-name'),
> + force => {
> + type => 'boolean',
> + description =>
> + 'Delete account data even if the server refuses to deactivate the account.',
> + optional => 1,
> + default => 0,
> + },
> },
> },
> returns => {
> @@ -319,7 +334,9 @@ __PACKAGE__->register_method ({
> code => sub {
> my ($param) = @_;
>
> - return $update_account->($param, 'deactivate', status => 'deactivated');
> + my $force_deactivate = extract_param($param, 'force');
> +
> + return $update_account->($param, 'deactivate', $force_deactivate, status => 'deactivated');
> }});
>
> __PACKAGE__->register_method ({
>
More information about the pmg-devel
mailing list