From b7e43b69d947e250e4df587c6377565638a49f1c Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Fri, 24 Apr 2020 12:23:13 +0200 Subject: [PATCH] 3CX, new version compat --- apps/voip/3cx/restapi/custom/api.pm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/apps/voip/3cx/restapi/custom/api.pm b/apps/voip/3cx/restapi/custom/api.pm index 4e41dbb42..783d01e42 100644 --- a/apps/voip/3cx/restapi/custom/api.pm +++ b/apps/voip/3cx/restapi/custom/api.pm @@ -136,9 +136,11 @@ sub settings { $self->build_options_for_httplib(); $self->{http}->add_header(key => 'Content-Type', value => 'application/json;charset=UTF-8'); - if (defined($self->{cookie}) && defined($self->{xsrf})) { + if (defined($self->{cookie})) { $self->{http}->add_header(key => 'Cookie', value => '.AspNetCore.Cookies=' . $self->{cookie}); - $self->{http}->add_header(key => 'X-XSRF-TOKEN', value => $self->{xsrf}); + if (defined($self->{xsrf})) { + $self->{http}->add_header(key => 'X-XSRF-TOKEN', value => $self->{xsrf}); + } } $self->{http}->set_options(%{$self->{option_results}}); } @@ -171,12 +173,9 @@ sub authenticate { $self->{output}->add_option_msg(short_msg => "Error retrieving cookie"); $self->{output}->option_exit(); } + # 3CX 16.0.5.611 does not use XSRF-TOKEN anymore if (defined ($header) && $header =~ /(?:^| )XSRF-TOKEN=([^;]+);.*/) { $xsrf = $1; - } else { - $self->{output}->output_add(long_msg => $content, debug => 1); - $self->{output}->add_option_msg(short_msg => "Error retrieving xsrf-token"); - $self->{output}->option_exit(); } my $datas = { last_timestamp => time(), cookie => $cookie, xsrf => $xsrf, expires_on => time() + (3600 * 24) };