From 10e12789a3f88aad0410ddcadea9ee60f72034c7 Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Fri, 18 Dec 2020 15:59:59 +0100
Subject: [PATCH] automatic computation of profiles list

---
 conf/manager.conf.in      | 3 ---
 lib/AccountManager/App.pm | 4 +++-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/conf/manager.conf.in b/conf/manager.conf.in
index 79723b6..56272cf 100644
--- a/conf/manager.conf.in
+++ b/conf/manager.conf.in
@@ -47,13 +47,10 @@ name = eduGAIN Access Check
 account_validity_period = 7
 # token validity period, in hours
 tokens_validity_period = 2
-# valid account profiles
-account_profiles = fullset1, limitedset1, generic1, student1, student2, teacher1, teacher2, alumni1, librarywalkin1, employee1, researcher1
 # override contacts defined in metadata if defined
 contacts = john@my.fqdn, sarah@my.fqdn
 
 # service-specific parameters
 [https://my.service.fqdn]
 account_validity_period = 90
-account_profiles = student1, teacher1
 contacts = john@my.fqdn
diff --git a/lib/AccountManager/App.pm b/lib/AccountManager/App.pm
index a73c8f5..96bebd2 100644
--- a/lib/AccountManager/App.pm
+++ b/lib/AccountManager/App.pm
@@ -491,7 +491,9 @@ sub req_complete_challenge {
         $token->secret(),
     );
 
-    my @profiles = split(/, */, $self->{configuration}->{service}->{account_profiles});
+    my @profiles =
+        map { m/([^\/]+).tt2$/ }
+        glob($self->{configuration}->{setup}->{templates_dir} . '/accounts/*.tt2' );
 
     $self->respond(
         template  => 'complete_challenge.tt2.html',
-- 
GitLab