Skip to content
Snippets Groups Projects
Commit a5e53a5d authored by Guillaume ROUSSE's avatar Guillaume ROUSSE
Browse files

replace contacts on the fly if needed

parent f02f2ee9
No related branches found
No related tags found
No related merge requests found
......@@ -270,7 +270,7 @@ sub req_select_sp {
if (!@$sps) {
push @{ $self->{out}->{errors} }, "no_such_entity";
$self->{logger}->errorf(
"No such entity %s in metadata", $self->{in}->{sp_entityid}
"No such SP '%s' in metadata", $self->{in}->{sp_entityid}
);
return undef;
}
......@@ -319,22 +319,26 @@ sub req_generate_token {
return undef;
}
## Create a serviceprovider object to load parameters for this SP from DB
my $service_provider = IdPAccountManager::Data::ServiceProvider->new(
db => $self->{db},
entityid => $self->{in}->{sp_entityid},
dev_sp_contact => $self->{configuration}->{dev_sp_contact}
my $provider = IdPAccountManager::Data::ServiceProvider->new(
db => $self->{db},
entityid => $self->{in}->{sp_entityid},
);
# Try loading DB object first
unless ($service_provider->load(speculative => 1)) {
push @{ $self->{out}->{errors} }, "internal";
$self->{logger}->errorf("Failed to load SP with entityid '%s'", $self->{in}->{sp_entityid});
unless ($provider->load(speculative => 1)) {
push @{ $self->{out}->{errors} }, "no_such_entity";
$self->{logger}->errorf("No such SP '%s' in database", $self->{in}->{sp_entityid});
return undef;
}
if ($self->{configuration}->{dev_sp_contact}) {
# replace SP contacts
$provider->contacts(
split(/, */, $self->{configuration}->{dev_sp_contact})
);
}
## Check that email_address is a known contact for this SP
unless ($service_provider->is_contact($self->{in}->{email_address}))
unless ($provider->is_contact($self->{in}->{email_address}))
{
push @{ $self->{out}->{errors} }, "internal";
$self->{logger}->errorf(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment