diff --git a/lib/IdPAccountManager/Data/ServiceProvider.pm b/lib/IdPAccountManager/Data/ServiceProvider.pm index 6eee98a97c61154fd3961b45cba54e34924e2937..bf8a4b787ce6bbd1367b81ce36185b7c81b57578 100644 --- a/lib/IdPAccountManager/Data/ServiceProvider.pm +++ b/lib/IdPAccountManager/Data/ServiceProvider.pm @@ -12,7 +12,7 @@ __PACKAGE__->meta->setup( id => { type => 'bigserial', not_null => 1 }, entityid => { type => 'varchar', length => 200, not_null => 1 }, displayname => { type => 'varchar', length => 500 }, - contacts => { type => 'varchar', length => 2000 }, + contacts => { type => 'array' }, ], primary_key_columns => [ 'id' ], @@ -25,8 +25,6 @@ sub new { my $self = $pkg->SUPER::new(%args); - $self->{dev_sp_contact} = $args{dev_sp_contact}; - return $self; } @@ -37,32 +35,17 @@ sub print { printf $fd "ServiceProvider ID=%s; entityid=%s; displayname=%s; contacts=%s\n", - $self->id(), $self->entityid(), $self->displayname(), $self->contacts(); -} - -## list contacts for this SP, including those listed in conf.dev_sp_contact -sub list_contacts_as_array { - my ($self) = @_; - - my %contact_list; - - foreach my $contact_email (split /,/, $self->contacts()) { - $contact_list{$contact_email}++; - } - - foreach my $contact_email (split /,/, $self->{dev_sp_contact}) { - $contact_list{$contact_email}++; - } - - return keys %contact_list; + $self->id(), $self->entityid(), $self->displayname(), join(',', $self->contacts()); } ## Check if email address is a known contact (or conf.dev_sp_contact) sub is_contact { my ($self, $email) = @_; - foreach my $known_contact ($self->list_contacts_as_array()) { - return 1 if (lc($email) eq lc($known_contact)); + $email = lc($email); + + foreach my $contact ($self->contacts()) { + return 1 if $email eq lc($contact); } return 0; diff --git a/lib/IdPAccountManager/WebRequest.pm b/lib/IdPAccountManager/WebRequest.pm index d7fec1e173a5458e4bed38014579e58ea9aefef4..970530474c96aafd7d94f19b14dd45e73a9a673e 100755 --- a/lib/IdPAccountManager/WebRequest.pm +++ b/lib/IdPAccountManager/WebRequest.pm @@ -277,9 +277,8 @@ sub req_select_sp { # complete persistent object $provider->displayname($sp->{display_name}); - $provider->contacts( - join(',', map { $_->{EmailAddress} } @{$sp->{contacts}}) - ) if $sp->{contacts}; + $provider->contacts(map { $_->{EmailAddress} } @{$sp->{contacts}}) + if $sp->{contacts}; # save in DB unless ($provider->save()) { diff --git a/templates/web/select_sp.tt2.html b/templates/web/select_sp.tt2.html index ce4e56ade15ba5425ebfcd32e4c02f231da98824..fe4356b6742fa5398e14e6bc3c8ee858070fb80a 100644 --- a/templates/web/select_sp.tt2.html +++ b/templates/web/select_sp.tt2.html @@ -11,7 +11,7 @@ Before you can create test accounts at this Identity Provider, we need to ensure <div class="radio_inline"> -[% FOREACH email IN provider.list_contacts_as_array.sort %] +[% FOREACH email IN provider.contacts.sort %] <input name="email_address" value="[% email %]" type="radio" class="required"/><label for="email_address">[% email %]</label><br/> <input type="hidden" name="sp_entityid" value="[% provider.entityid %]" id="sp_entityid"/>