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
Branches
Tags
No related merge requests found
...@@ -63,9 +63,21 @@ sub new { ...@@ -63,9 +63,21 @@ sub new {
} }
$self->{logger} = Log::Any->get_logger(); $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}) { if (!$self->{configuration}->{mailer}) {
$self->{logger}->fatal( $self->{logger}->fatal(
...@@ -194,9 +206,16 @@ sub respond { ...@@ -194,9 +206,16 @@ sub respond {
binmode(STDOUT, ":utf8"); binmode(STDOUT, ":utf8");
my $cookie = $self->{cgi}->cookie(
-name => 'lang',
-value => $self->{lh}->language_tag(),
-expires => undef,
);
print $self->{cgi}->header( print $self->{cgi}->header(
-type => 'text/html', -type => 'text/html',
-charset => 'utf8' -charset => 'utf8',
-cookie => [ $cookie ]
); );
unless ($tt2->process($in{template}, $in{data}, \*STDOUT)) { unless ($tt2->process($in{template}, $in{data}, \*STDOUT)) {
...@@ -228,6 +247,7 @@ sub req_select_federation { ...@@ -228,6 +247,7 @@ sub req_select_federation {
$self->respond( $self->respond(
template => 'select_federation.tt2.html', template => 'select_federation.tt2.html',
data => { data => {
action => 'select_federation',
federations => \@federations federations => \@federations
} }
); );
...@@ -279,6 +299,7 @@ sub req_select_sp { ...@@ -279,6 +299,7 @@ sub req_select_sp {
$self->respond( $self->respond(
template => 'select_sp.tt2.html', template => 'select_sp.tt2.html',
data => { data => {
action => 'select_sp',
metadata => $metadata->parse(type => 'sp'), metadata => $metadata->parse(type => 'sp'),
federation => $federation, federation => $federation,
} }
...@@ -407,8 +428,10 @@ sub req_select_email { ...@@ -407,8 +428,10 @@ sub req_select_email {
$self->respond( $self->respond(
template => 'select_email.tt2.html', template => 'select_email.tt2.html',
data => { data => {
action => 'select_email',
federation => $federation, federation => $federation,
sp => $sp, sp => $sp,
entityid => $sp->entityid(),
} }
); );
} }
...@@ -608,6 +631,7 @@ sub req_complete_challenge { ...@@ -608,6 +631,7 @@ sub req_complete_challenge {
$self->respond( $self->respond(
template => 'complete_challenge.tt2.html', template => 'complete_challenge.tt2.html',
data => { data => {
action => 'complete_challenge',
federation => $federation, federation => $federation,
entityid => $self->{in}->{entityid}, entityid => $self->{in}->{entityid},
email => $self->{in}->{email}, email => $self->{in}->{email},
...@@ -787,8 +811,10 @@ sub req_create_accounts { ...@@ -787,8 +811,10 @@ sub req_create_accounts {
$self->respond( $self->respond(
template => 'create_accounts.tt2.html', template => 'create_accounts.tt2.html',
data => { data => {
action => 'create_accounts',
accounts => \@accounts, accounts => \@accounts,
entityid => $self->{in}->{entityid}, entityid => $self->{in}->{entityid},
email => $self->{in}->{email},
key => $key, key => $key,
token => $download_token->token(), token => $download_token->token(),
days => $validity_period, days => $validity_period,
...@@ -929,6 +955,9 @@ sub req_home { ...@@ -929,6 +955,9 @@ sub req_home {
$self->respond( $self->respond(
template => 'home.tt2.html', 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