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

transfer presentation complexity from code to templates

parent 871f3fa7
No related branches found
No related tags found
No related merge requests found
......@@ -254,71 +254,32 @@ sub req_select_sp {
$self->check_authentication(action => 'select_sp')
if $self->{configuration}->{app}->{login_url};
my @groups;
my @organization_entities;
foreach my $id (split(/, */, $self->{configuration}->{groups}->{list})) {
my $spec = $self->{configuration}->{$id};
if ($spec->{type} eq 'metadata') {
my $entities = AccountManager::Entity->get_entities(
db => $self->{db},
query => [
type => { eq => 'sp' },
federations => { like => "%\"$id\"%" }
],
debug => 1
);
push @groups, {
id => $id,
label => $spec->{label},
type => 'list',
entities => $entities
};
} elsif ($spec->{type} eq 'organization') {
next unless $ENV{HTTP_SHIB_IDENTITY_PROVIDER};
my $idps = AccountManager::Entity->get_entities(
db => $self->{db},
query => [
type => 'idp',
entityid => $ENV{HTTP_SHIB_IDENTITY_PROVIDER},
]
);
my $idp = $idps->[0];
next unless $idp;
my $entities = AccountManager::Entity->get_entities(
db => $self->{db},
query => [
type => 'sp',
organization_url => $idp->organization_url()
]
);
push @groups, {
id => $id,
label => $spec->{label},
type => 'list',
entities => $entities
};
} elsif ($spec->{type} eq 'link') {
push @groups, {
id => $id,
label => $spec->{label},
type => 'link',
url => $spec->{url},
message => $spec->{message},
};
}
my $sps = AccountManager::Entity->get_entities(
db => $self->{db},
query => [
type => 'sp',
],
sort_by => 'display_name'
);
my $idp;
if ($ENV{HTTP_SHIB_IDENTITY_PROVIDER}) {
my $idps = AccountManager::Entity->get_entities(
db => $self->{db},
query => [
type => 'idp',
entityid => $ENV{HTTP_SHIB_IDENTITY_PROVIDER},
]
);
$idp = $idps->[0];
}
$self->respond(
template => 'select_sp.tt2.html',
data => {
action => 'select_sp',
groups => \@groups,
sps => $sps,
idp => $idp,
}
);
}
......
......@@ -50,5 +50,11 @@ sub is_contact {
return any { $email eq lc($_) } $self->contacts();
}
sub is_member_of {
my ($self, $federation) = @_;
return any { $federation eq $_ } $self->federations();
}
1;
......@@ -48,6 +48,22 @@ msgstr "Ces attributs sont transmis via le protocole SAML, après une authentifi
msgid "All rights reserved"
msgstr "Tous droits réservés"
#: templates/web/edugain/select_sp.tt2.html:33
msgid "All service providers"
msgstr "Tous les fournisseurs de service"
#: templates/web/renater/select_sp.tt2.html:33
msgid "All service providers registered in Education-Research federation"
msgstr "Tous les fournisseurs de service enregistrés dans la fédération Education-Recherche"
#: templates/web/renater/select_sp.tt2.html:55
msgid "All service providers registered in eduGAIN federation"
msgstr "Tous les fournisseurs de service enregistrés dans la fédération eduGAIN"
#: templates/web/renater/select_sp.tt2.html:44
msgid "All service providers registered in test federation"
msgstr "Tous les fournisseurs de service enregistrés dans la fédération de test"
#. (email)
#: templates/web/edugain/complete_challenge.tt2.html:14 templates/web/renater/complete_challenge.tt2.html:14
msgid "An email challenge including a validation token has been emailed to you at %1."
......
......@@ -15,22 +15,29 @@
[% lh.maketext("You must be an administrator of that service to continue afterwards.") %]
</p>
[% FOREACH group IN groups %]
[% IF idp %]
<fieldset>
<legend>[% lh.maketext(group.label) %]</legend>
[% SWITCH group.type %]
[% CASE 'list' %]
<select id="[% group.id %]" name="[% group.id %]">
<legend>[% lh.maketext("Service providers from my own organization") %]</legend>
<select id="self" name="self">
<option value=""></option>
[% FOREACH entity IN group.entities.sort('display_name') %]
<option value="[% entity.entityid %]">[% entity.display_name %]</option>
[% END %]
[% organization_url == idp.organization_url() %]
[% FOREACH sp IN sps %]
[% NEXT UNLESS sp.organization_url() == organization_url %]
<option value="[% sp.entityid() %]">[% sp.display_name() %]</option>
[% END %]
</select>
[% CASE 'link' %]
<a class="button" href="[% group.url %]">[% lh.maketext(group.message) %]</a>
</fieldset>
[% END %]
<fieldset>
<legend>[% lh.maketext("All service providers") %]</legend>
<select id="all" name="all">
<option value=""></option>
[% FOREACH sp IN sps %]
<option value="[% sp.entityid() %]">[% sp.display_name() %]</option>
[% END %]
</select>
</fieldset>
[% END %]
<input type="hidden" id="entityid" name="entityid"/>
<div class="callout primary">[% lh.maketext("Those service providers have been extracted from federation metadata.") %]</div>
......@@ -184,10 +191,10 @@ $( document ).ready(function() {
}
});
[% FOREACH group IN groups %]
[% NEXT IF group.type != 'list' %]
$( "#[% group.id %]" ).combobox();
[% END %]
[% IF idp %]
$("#self").combobox();
[% END %]
$( "#all" ).combobox();
$.validator.messages.required = "[% lh.maketext("This information is required") %]";
$("form").validate();
......
......@@ -15,22 +15,47 @@
[% lh.maketext("You must be an administrator of that service to continue afterwards.") %]
</p>
[% FOREACH group IN groups %]
[% IF idp %]
<fieldset>
<legend>[% lh.maketext(group.label) %]</legend>
[% SWITCH group.type %]
[% CASE 'list' %]
<select id="[% group.id %]" name="[% group.id %]">
<legend>[% lh.maketext("Service providers from my own organization") %]</legend>
<select id="self" name="self">
<option value=""></option>
[% FOREACH entity IN group.entities.sort('display_name') %]
<option value="[% entity.entityid %]">[% entity.display_name %]</option>
[% END %]
[% organization_url == idp.organization_url() %]
[% FOREACH sp IN sps %]
[% NEXT UNLESS sp.organization_url() == organization_url %]
<option value="[% sp.entityid() %]">[% sp.display_name() %]</option>
[% END %]
</select>
[% CASE 'link' %]
<a class="button" href="[% group.url %]">[% lh.maketext(group.message) %]</a>
</fieldset>
[% END %]
<fieldset>
<legend>[% lh.maketext("All service providers registered in Education-Research federation") %]</legend>
<select id="renater" name="renater">
<option value=""></option>
[% FOREACH sp IN sps %]
[% NEXT UNLESS sp.is_member_of('renater') %]
<option value="[% sp.entityid() %]">[% sp.display_name() %]</option>
[% END %]
</select>
</fieldset>
[% END %]
<fieldset>
<legend>[% lh.maketext("All service providers registered in test federation") %]</legend>
<select id="test" name="test">
<option value=""></option>
[% FOREACH sp IN sps %]
[% NEXT UNLESS sp.is_member_of('test') %]
<option value="[% sp.entityid() %]">[% sp.display_name() %]</option>
[% END %]
</select>
</fieldset>
<fieldset>
<legend>[% lh.maketext("All service providers registered in eduGAIN federation") %]</legend>
<a class="button" href="https://access-check.edugain.org">[% lh.maketext("eduGAIN Access Check") %]</a>
</fieldset>
<input type="hidden" id="entityid" name="entityid"/>
<div class="callout alert-callout-border primary">[% lh.maketext("Those service providers have been extracted from federation metadata.") %]</div>
......@@ -185,10 +210,11 @@ $( document ).ready(function() {
}
});
[% FOREACH group IN groups %]
[% NEXT IF group.type != 'list' %]
$( "#[% group.id %]" ).combobox();
[% END %]
[% IF idp %]
$("#self").combobox();
[% END %]
$("#renater").combobox();
$("#test").combobox();
$.validator.messages.required = "[% lh.maketext("This information is required") %]";
$("form").validate();
......
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