[pmg-devel] [PATCH api 2/4] support forced account deactivation
Wolfgang Bumiller
w.bumiller at proxmox.com
Wed Mar 17 11:02:14 CET 2021
Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
src/PMG/API2/ACME.pm | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
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;
+ }
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 ({
--
2.20.1
More information about the pmg-devel
mailing list