diff --git a/bin/mozilla/login.pl b/bin/mozilla/login.pl index 8cffe238..ee368509 100644 --- a/bin/mozilla/login.pl +++ b/bin/mozilla/login.pl @@ -15,11 +15,22 @@ use SL::User; use SL::Form; use SL::Locale; +use Storable (); + +sub h { + my ($s) = @_; + $s = '' unless defined $s; + $s =~ s/&/&/g; + $s =~ s//>/g; + $s =~ s/"/"/g; + $s =~ s/'/'/g; + return $s; +} $form = SL::Form->new; - $locale = SL::Locale->new($slconfig{language}, "login"); # $form->{charset} = $slconfig{charset}; @@ -42,98 +53,176 @@ &login_screen; } - 1; +sub login_env_html { + my ($form, $locale) = @_; -sub login_screen { + my $env = $form->environment; - $form->{stylesheet} = "sql-ledger.css"; - $form->{favicon} = "favicon.ico"; + my %env_label = ( + dev => $locale->text('Development Environment'), + test => $locale->text('Test Environment'), + ); - $form->header; + my $version_label = $locale->text('Version'); - $focus = ($form->{login}) ? "password" : "login"; + if (exists $env_label{$env}) { + return qq{ +
+
+

$env_label{$env}

+

$version_label $form->{version}-$form->{cssversion}

+
+
+ }; + } - print qq| - + return qq{ +
+
+

$version_label $form->{version}-$form->{cssversion}

+
+
+ }; +} -
+sub login_screen {
 
+  $form->{stylesheet} = "blue.css";
+  $form->{favicon} = "favicon.ico";
 
+  $form->header;
 
+  $focus = ($form->{login}) ? "user" : "login";
 
+  my $env_html = login_env_html($form, $locale);
 
+  print qq|
+
+
+
+ +
-
+ @@ -146,76 +235,117 @@ sub login_screen { sub selectdataset { my ($login) = @_; - if (-f "css/sql-ledger.css") { - $form->{stylesheet} = "sql-ledger.css"; + if (-f "css/blue.css") { + $form->{stylesheet} = "blue.css"; } if (-f 'favicon.ico') { $form->{favicon} = "favicon.ico"; } - delete $self->{sessioncookie}; + delete $form->{sessioncookie}; $form->header(1); - print qq| - - -
+  my $env_html = login_env_html($form, $locale);
+  my $login_h  = h($form->{login});
 
-
- -
- - - - - - - - - - - - - |; + +
$user->{totp_secret}
+ |; } $form->{stylesheet} = $user->{stylesheet}; @@ -559,50 +821,75 @@ sub totp_screen { $form->header; - print qq| - - - -
-
-
- -
-
|.$locale->text('Scan the following code with your Authenticator App:').qq|
 
+
+
|.$locale->text('Scan the following code with your Authenticator App:').qq|
+
|. SL::QRCode::plot_svg(SL::TOTP::url($user), scale => 4) . qq| -
$user->{totp_secret}
 
- - - -
+ @@ -636,8 +923,10 @@ sub totp_login { # made it this far, setup callback for the menu $form->{callback} = "menu.pl?action=display"; - for (qw(login path password js sessioncookie small_device)) { - $form->{callback} .= "&$_=$form->{$_}"; + for my $k (qw(login path js sessioncookie small_device)) { + my $v = $form->{$k}; + next unless defined $v; + $form->{callback} .= "&$k=" . $form->escape($v, 1); } # check for recurring transactions