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

allow user to select list of account profiles

parent 1c62e835
No related branches found
No related tags found
No related merge requests found
......@@ -491,6 +491,8 @@ sub req_complete_challenge {
$token->secret(),
);
my @profiles = split(/, */, $self->{configuration}->{service}->{account_profiles});
$self->respond(
template => 'complete_challenge.tt2.html',
data => {
......@@ -498,6 +500,7 @@ sub req_complete_challenge {
entityid => $entityid,
email => $email,
validity => $self->{configuration}->{service}->{account_validity_period},
profiles => \@profiles
}
);
}
......@@ -512,6 +515,7 @@ sub req_create_accounts {
my $token = $self->get_parameter(name => 'token');
my $email = $self->get_parameter(name => 'email');
my $validity = $self->get_parameter(name => 'validity');
my @profiles = $self->get_multivalued_parameter(name => 'profiles');
$self->check_token(token => $token, entityid => $entityid);
......@@ -527,10 +531,6 @@ sub req_create_accounts {
## create test accounts
my @accounts;
my $profiles =
$self->{configuration}->{$entityid}->{account_profiles} ||
$self->{configuration}->{service}->{account_profiles};
my $creation_date = DateTime->now();
my $token_expiration_date = DateTime->now()->add(
hours => $self->{configuration}->{service}->{tokens_validity_period}
......@@ -555,7 +555,7 @@ sub req_create_accounts {
my $key = AccountManager::Tools::generate_secret(10);
foreach my $profile (split(/, */, $profiles)) {
foreach my $profile (@profiles) {
my $password = AccountManager::Tools::generate_password(10);
my $account = AccountManager::Account->new(
db => $self->{db},
......@@ -743,6 +743,27 @@ sub get_parameter {
return $value;
}
sub get_multivalued_parameter {
my ($self, %args) = @_;
my $name = $args{name};
my @values = $self->{cgi}->param($name);
$self->abort(
log => "Missing parameter: $name",
user => "missing_$name"
) if !@values;
if ($patterns{$name}) {
$self->abort(
log => "Incorrect parameter format: $name",
user => "format_$name"
) if any { $_ !~ $patterns{$name} } @values;
}
return @values;
}
sub get_metadata_file {
my ($self, %args) = @_;
......
......@@ -35,6 +35,10 @@ msgstr "À propos"
msgid "Account profile: %1"
msgstr "Profil d'utilisateur: %1"
#: templates/web/renater/complete_challenge.tt2.html:26
msgid "Account profiles:"
msgstr "Profils d'utilisateur:"
#: templates/web/renater/complete_challenge.tt2.html:22
msgid "Accounts validity period, in days:"
msgstr "Durée de validité des comptes, en jours:"
......
......@@ -22,6 +22,15 @@
<legend>[% lh.maketext("Accounts validity period, in days:") %]</legend>
<input name="validity" value="[% validity %]" id="validity" type="number" class="required" min="1"/>
</fieldset>
<fieldset>
<legend>[% lh.maketext("Account profiles:") %]</legend>
[% FOREACH profile IN profiles %]
[% template = profile _ '.tt2' %]
[% PROCESS $template scope=account.scope() id=account.id() | trim %]
<input type="checkbox" name="profiles" value="[% profile %]" checked/>[% profile %]: [% description.${lh.language_tag()} %]<br>
[% END %]
</fieldset>
<input type="hidden" name="federation" value="[% federation %]"/>
<input type="hidden" name="entityid" value="[% entityid %]"/>
<input type="hidden" name="email" value="[% email %]"/>
......
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