From a5e04fc5f7f43fa7c624127476a9a5c6f19f1162 Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Tue, 11 Dec 2018 12:51:34 +0100
Subject: [PATCH] a bit more consistency in variable names

---
 lib/AccountManager/App.pm                      | 18 +++++++++++++-----
 .../mail/send_authentication_token.tt2.html    |  2 +-
 .../mail/send_authentication_token.tt2.txt     |  2 +-
 templates/web/edugain/create_accounts.tt2.html | 10 +++++-----
 templates/web/renater/create_accounts.tt2.html | 10 +++++-----
 5 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/lib/AccountManager/App.pm b/lib/AccountManager/App.pm
index e5acaa4..d184458 100644
--- a/lib/AccountManager/App.pm
+++ b/lib/AccountManager/App.pm
@@ -468,8 +468,12 @@ sub req_complete_challenge {
             name          => $self->{configuration}->{app}->{name},
         },
         user      => $user,
-        idp       => $idp,
-        sp        => $entityid,
+        idp       => {
+            entityid => $idp,
+        },
+        sp        => {
+            entityid => $entityid,
+        },
         to        => $email,
         token     => $token->secret(),
         challenge_url => sprintf(
@@ -645,9 +649,13 @@ sub req_create_accounts {
         data     => {
             action   => 'create_accounts',
             accounts => \@accounts,
-            entityid => $entityid,
-            idp      => $self->{configuration}->{idp}->{name},
-            url      => $sp->information_url(),
+            idp      => {
+                name => $self->{configuration}->{idp}->{name},
+            },
+            sp       => {
+                entityid => $entityid,
+                url      => $sp->information_url(),
+            },
             email    => $email,
             key      => $key,
             token    => $download_token->secret(),
diff --git a/templates/mail/send_authentication_token.tt2.html b/templates/mail/send_authentication_token.tt2.html
index f4c203a..1114551 100644
--- a/templates/mail/send_authentication_token.tt2.html
+++ b/templates/mail/send_authentication_token.tt2.html
@@ -1,6 +1,6 @@
 <p>
     [% lh.maketext("This is an email challenge automatically sent to you by [_1].", app.name) %] 
-    [% lh.maketext("User [_1], authenticated by Identity Provider [_2], has requested creation of test accounts for Service Provider [_3].", user, idp, sp) %] 
+    [% lh.maketext("User [_1], authenticated by Identity Provider [_2], has requested creation of test accounts for Service Provider [_3].", user, idp.entityid, sp.entityid) %]
     [% lh.maketext("The address [_1] is mentioned in the federation metadata as a contact for this Service Provider.", to) %]
 </p>
 
diff --git a/templates/mail/send_authentication_token.tt2.txt b/templates/mail/send_authentication_token.tt2.txt
index 091a5fb..953d62b 100644
--- a/templates/mail/send_authentication_token.tt2.txt
+++ b/templates/mail/send_authentication_token.tt2.txt
@@ -1,5 +1,5 @@
 [% lh.maketext("This is an email challenge automatically sent to you by [_1].", app.name) %]
-[% lh.maketext("User [_1], authenticated by Identity Provider [_2], has requested creation of test accounts for Service Provider [_3].", user, idp, sp) %] 
+[% lh.maketext("User [_1], authenticated by Identity Provider [_2], has requested creation of test accounts for Service Provider [_3].", user, idp.entityid, sp.entityid) %] 
 [% lh.maketext("The address [_1] is mentioned in the federation metadata as a contact for this Service Provider.", to) %]
 
 [% lh.maketext("To complete the creation of test accounts, paste the following validation token in [_1]:", app.name) %]
diff --git a/templates/web/edugain/create_accounts.tt2.html b/templates/web/edugain/create_accounts.tt2.html
index 4fed7df..40f47d5 100644
--- a/templates/web/edugain/create_accounts.tt2.html
+++ b/templates/web/edugain/create_accounts.tt2.html
@@ -1,17 +1,17 @@
 [% WRAPPER index.tt2.html %]
 <div class="row">
     <div class="callout success">
-        [% lh.maketext("<strong>Success:</strong> your identity as administrator of the Service Provider <strong>[_1]</strong> has been validated!", entityid) %]
+        [% lh.maketext("<strong>Success:</strong> your identity as administrator of the Service Provider <strong>[_1]</strong> has been validated!", sp.entityid) %]
     </div>
 </div>
 
 <h2>[% lh.maketext("Test accounts created") %]</h2>
 <p>
-[% lh.maketext("You can now use these test accounts to login at your <a href=\"[_1]\">service provider</a>.", url) %]
-[% lh.maketext("To do so, select <strong>[_1]</strong> when choosing an identity provider.", idp) %]
+[% lh.maketext("You can now use these test accounts to login at your <a href=\"[_1]\">service provider</a>.", sp.url) %]
+[% lh.maketext("To do so, select <strong>[_1]</strong> when choosing an identity provider.", idp.name) %]
 </p>
 
-<p><a class="button" href="[% app.url %]?action=download_accounts&entityid=[% entityid %]&token=[% token %]&key=[% key %]">[% lh.maketext("Download in CSV format") %]</a></p>
+<p><a class="button" href="[% app.url %]?action=download_accounts&entityid=[% sp.entityid %]&token=[% token %]&key=[% key %]">[% lh.maketext("Download in CSV format") %]</a></p>
 
 <div class="accounts row">
     [% FOREACH account IN accounts %]
@@ -81,7 +81,7 @@
 
 <div class="row">
     <div class="callout warning">
-        <p>[% lh.maketext("Note that these test accounts will automatically expire in [_1] days and that they can only be used to test federated login to your service provider <strong>[_2]</strong>.", days, entityid) %]</p>
+        <p>[% lh.maketext("Note that these test accounts will automatically expire in [_1] days and that they can only be used to test federated login to your service provider <strong>[_2]</strong>.", days, sp.entityid) %]</p>
     </div>
 </div>
 
diff --git a/templates/web/renater/create_accounts.tt2.html b/templates/web/renater/create_accounts.tt2.html
index 10d9798..6156615 100644
--- a/templates/web/renater/create_accounts.tt2.html
+++ b/templates/web/renater/create_accounts.tt2.html
@@ -2,18 +2,18 @@
 <div class="row">
     <div class="small-12 columns">
         <p class="callout alert-callout-border success text-center">
-        [% lh.maketext("<strong>Success:</strong> your identity as administrator of the Service Provider <strong>[_1]</strong> has been validated!", entityid) %]
+        [% lh.maketext("<strong>Success:</strong> your identity as administrator of the Service Provider <strong>[_1]</strong> has been validated!", sp.entityid) %]
         </p>
     </div>
 </div>
 
 <h2>[% lh.maketext("Test accounts created") %]</h2>
 <p>
-[% lh.maketext("You can now use these test accounts to login at your <a href=\"[_1]\">service provider</a>.", url) %]
-[% lh.maketext("To do so, select <strong>[_1]</strong> when choosing an identity provider.", idp) %]
+[% lh.maketext("You can now use these test accounts to login at your <a href=\"[_1]\">service provider</a>.", sp.url) %]
+[% lh.maketext("To do so, select <strong>[_1]</strong> when choosing an identity provider.", idp.name) %]
 </p>
 
-<p><a class="button" href="[% app.url %]?action=download_accounts&entityid=[% entityid %]&token=[% token %]&key=[% key %]">[% lh.maketext("Download in CSV format") %]</a></p>
+<p><a class="button" href="[% app.url %]?action=download_accounts&entityid=[% sp.entityid %]&token=[% token %]&key=[% key %]">[% lh.maketext("Download in CSV format") %]</a></p>
 
 <div class="accounts row">
     [% FOREACH account IN accounts %]
@@ -85,7 +85,7 @@
 
 <div class="row">
     <div class="callout alert-callout-border warning">
-        <p>[% lh.maketext("Note that these test accounts will automatically expire in [_1] days and that they can only be used to test federated login to your service provider <strong>[_2]</strong>.", days, entityid) %]</p>
+        <p>[% lh.maketext("Note that these test accounts will automatically expire in [_1] days and that they can only be used to test federated login to your service provider <strong>[_2]</strong>.", days, sp.entityid) %]</p>
     </div>
 </div>
 
-- 
GitLab