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

sticky language preference support, through cookie

Additionally, all templates now receive all needed arguments to generate
a link with full current state
parent 689c099e
No related branches found
No related tags found
No related merge requests found
......@@ -63,9 +63,21 @@ sub new {
}
$self->{logger} = Log::Any->get_logger();
$self->{lh} = AccountManager::L10N->get_handle();
$self->{cgi} = CGI->new();
$self->{cgi} = CGI->new();
my $lang =
$self->{cgi}->param('lang') ||
$self->{cgi}->cookie('lang');
$self->{lh} = AccountManager::L10N->get_handle($lang ? $lang: ());
if (!$self->{lh}) {
$self->{logger}->fatal("Unable to get suitable language handle");
$self->respond(
template => 'errors.tt2.html',
data => {
errors => [ 'internal' ]
}
);
}
if (!$self->{configuration}->{mailer}) {
$self->{logger}->fatal(
......@@ -194,9 +206,16 @@ sub respond {
binmode(STDOUT, ":utf8");
my $cookie = $self->{cgi}->cookie(
-name => 'lang',
-value => $self->{lh}->language_tag(),
-expires => undef,
);
print $self->{cgi}->header(
-type => 'text/html',
-charset => 'utf8'
-charset => 'utf8',
-cookie => [ $cookie ]
);
unless ($tt2->process($in{template}, $in{data}, \*STDOUT)) {
......@@ -228,6 +247,7 @@ sub req_select_federation {
$self->respond(
template => 'select_federation.tt2.html',
data => {
action => 'select_federation',
federations => \@federations
}
);
......@@ -279,6 +299,7 @@ sub req_select_sp {
$self->respond(
template => 'select_sp.tt2.html',
data => {
action => 'select_sp',
metadata => $metadata->parse(type => 'sp'),
federation => $federation,
}
......@@ -407,8 +428,10 @@ sub req_select_email {
$self->respond(
template => 'select_email.tt2.html',
data => {
action => 'select_email',
federation => $federation,
sp => $sp,
entityid => $sp->entityid(),
}
);
}
......@@ -608,6 +631,7 @@ sub req_complete_challenge {
$self->respond(
template => 'complete_challenge.tt2.html',
data => {
action => 'complete_challenge',
federation => $federation,
entityid => $self->{in}->{entityid},
email => $self->{in}->{email},
......@@ -787,8 +811,10 @@ sub req_create_accounts {
$self->respond(
template => 'create_accounts.tt2.html',
data => {
action => 'create_accounts',
accounts => \@accounts,
entityid => $self->{in}->{entityid},
email => $self->{in}->{email},
key => $key,
token => $download_token->token(),
days => $validity_period,
......@@ -929,6 +955,9 @@ sub req_home {
$self->respond(
template => 'home.tt2.html',
data => {
action => 'home'
}
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment