From 8901e33f0d1f6a06ab1b9914f23165de0554f703 Mon Sep 17 00:00:00 2001 From: Guillaume Rousse <guillaume.rousse@renater.fr> Date: Tue, 30 Jan 2018 15:14:56 +0100 Subject: [PATCH] allow either to replace or complete provider contacts --- lib/AccountManager/WebRequest.pm | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/AccountManager/WebRequest.pm b/lib/AccountManager/WebRequest.pm index 581111a..a1c978c 100644 --- a/lib/AccountManager/WebRequest.pm +++ b/lib/AccountManager/WebRequest.pm @@ -262,12 +262,20 @@ sub req_select_sp { } } - # replace metadata contacts from configuration contacts if defined + # override metadata contacts if needed my $entity = $self->{in}->{sp_entityid}; my $contacts = $self->{configuration}->{$entity}->{contacts} || $self->{configuration}->{service}->{contacts}; - $provider->contacts(split(/, */, $contacts)) if $contacts; + if ($contacts) { + if ($contacts =~ /^\+(.+)/) { + # complement original contacts + $provider->contacts($provider->contacts(), split(/, */, $1)); + } else { + # replace original contacts + $provider->contacts(split(/, */, $contacts)); + } + } $self->{out}->{provider} = $provider; $self->{out}->{subtitle} = 'Select your Service Provider'; @@ -303,12 +311,20 @@ sub req_generate_token { return; } - # replace metadata contacts from configuration contacts if defined + # override metadata contacts if needed my $entity = $self->{in}->{sp_entityid}; my $contacts = $self->{configuration}->{$entity}->{contacts} || $self->{configuration}->{service}->{contacts}; - $provider->contacts(split(/, */, $contacts)) if $contacts; + if ($contacts) { + if ($contacts =~ /^\+(.+)/) { + # complement original contacts + $provider->contacts($provider->contacts(), split(/, */, $1)); + } else { + # replace original contacts + $provider->contacts(split(/, */, $contacts)); + } + } ## Check that email_address is a known contact for this SP unless ($provider->is_contact($self->{in}->{email_address})) -- GitLab