From ac80236febf4814d18484d0cbe7d9054c5424918 Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Thu, 24 May 2018 14:56:21 +0200
Subject: [PATCH] start with second step if there is just one federation

---
 lib/AccountManager/App.pm   | 15 ++++++++++++++-
 templates/web/home.tt2.html |  2 +-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/lib/AccountManager/App.pm b/lib/AccountManager/App.pm
index 182e110..9bf24e6 100644
--- a/lib/AccountManager/App.pm
+++ b/lib/AccountManager/App.pm
@@ -33,6 +33,7 @@ my $entity_id_pattern = qr{
 
 my %actions = (
     home               => 'req_home',
+    start              => 'req_start',
     select_federation  => 'req_select_federation',
     select_sp          => 'req_select_sp',
     select_email       => 'req_select_email',
@@ -131,7 +132,6 @@ sub new {
 sub run {
     my ($self) = @_;
 
-
     # process input parameters
     my %parameters = $self->{cgi}->Vars();
 
@@ -207,6 +207,19 @@ sub respond {
     exit 0;
 }
 
+sub req_start {
+    my ($self) = @_;
+
+    my @federations = keys %{$self->{configuration}->{federations}};
+    if (@federations == 1) {
+        $self->{in}->{federation} = $federations[0];
+        $self->req_select_sp();
+    } else {
+        $self->req_select_federation();
+    }
+}
+
+
 sub req_select_federation {
     my ($self) = @_;
 
diff --git a/templates/web/home.tt2.html b/templates/web/home.tt2.html
index 6fff1a9..3217f3e 100644
--- a/templates/web/home.tt2.html
+++ b/templates/web/home.tt2.html
@@ -17,6 +17,6 @@
 
 <h2>[% lh.maketext("Get started") %]</h2>
 <p>[% lh.maketext("To start testing your own services, start by selecting one your are administrator for.") %]</p>
-<p class="text-center"><a href="[% app.url %]?action=select_federation" class="button">[% lh.maketext("Get started") %]</a></p>
+<p class="text-center"><a href="[% app.url %]?action=start" class="button">[% lh.maketext("Get started") %]</a></p>
 
 [% END %]
-- 
GitLab