Globale Variablen für Systemeinstellungen und Features nach %::lx_office_conf verschoben
[kivitendo-erp.git] / bin / mozilla / login.pl
index 5a5aa42..49cb6c6 100644 (file)
@@ -39,7 +39,6 @@ use strict;
 
 our $cgi;
 our $form;
-our $locale;
 our $auth;
 
 sub run {
@@ -48,33 +47,33 @@ sub run {
 
   $cgi    = $::cgi;
   $form   = $::form;
-  $locale = $::locale;
   $auth   = $::auth;
 
   $form->{stylesheet} = "lx-office-erp.css";
   $form->{favicon}    = "favicon.ico";
 
   if (SL::Auth::SESSION_EXPIRED == $session_result) {
-    $form->{error_message} = $locale->text('The session is invalid or has expired.');
+    $form->{error_message} = $::locale->text('The session is invalid or has expired.');
     login_screen();
-    exit;
+    ::end_of_request();
   }
   my $action = $form->{action};
   if (!$action && $auth->{SESSION}->{login}) {
     $action = 'login';
   }
   if ($action) {
-    our %myconfig = $auth->read_user($form->{login}) if ($form->{login});
+    %::myconfig = $auth->read_user($form->{login}) if ($form->{login});
+    $::locale   = Locale->new($::myconfig{countrycode}) if $::myconfig{countrycode};
 
-    if (!$myconfig{login} || (SL::Auth::OK != $auth->authenticate($form->{login}, $form->{password}, 0))) {
-      $form->{error_message} = $locale->text('Incorrect Password!');
+    if (!$::myconfig{login} || (SL::Auth::OK != $auth->authenticate($form->{login}, $form->{password}, 0))) {
+      $form->{error_message} = $::locale->text('Incorrect username or password!');
       login_screen();
     } else {
       $auth->set_session_value('login', $form->{login}, 'password', $form->{password});
       $auth->create_or_refresh_session();
 
-      $form->{titlebar} .= " - $myconfig{name} - $myconfig{dbname}";
-      call_sub($locale->findsub($action));
+      $form->{titlebar} .= " - $::myconfig{name} - $::myconfig{dbname}";
+      call_sub($::locale->findsub($action));
     }
   } else {
     login_screen();
@@ -103,8 +102,8 @@ sub login {
   $main::lxdebug->enter_sub();
 
   unless ($form->{login}) {
-    login_screen($locale->text('You did not enter a name!'));
-    exit;
+    login_screen($::locale->text('You did not enter a name!'));
+    ::end_of_request();
   }
 
   my $user = new User $form->{login};
@@ -112,9 +111,9 @@ sub login {
   # if we get an error back, bale out
   my $result;
   if (($result = $user->login($form)) <= -1) {
-    exit if $result == -2;
-    login_screen($locale->text('Incorrect username or password!'));
-    exit;
+    ::end_of_request() if $result == -2;
+    login_screen($::locale->text('Incorrect username or password!'));
+    ::end_of_request();
   }
 
   my %style_to_script_map = ( 'v3'  => 'v3',
@@ -151,7 +150,7 @@ sub logout {
 
   # remove the callback to display the message
   $form->{callback} = "login.pl?action=";
-  $form->redirect($locale->text('You are logged out!'));
+  $form->redirect($::locale->text('You are logged out!'));
 
   $main::lxdebug->leave_sub();
 }
@@ -160,12 +159,10 @@ sub company_logo {
   $main::lxdebug->enter_sub();
 
   my %myconfig = %main::myconfig;
-  $locale             =  new Locale $myconfig{countrycode}, "login" if ($main::language ne $myconfig{countrycode});
-
   $form->{todo_list}  =  create_todo_list('login_screen' => 1) if (!$form->{no_todo_list});
 
   $form->{stylesheet} =  $myconfig{stylesheet};
-  $form->{title}      =  $locale->text('About');
+  $form->{title}      =  $::locale->text('Lx-Office');
 
   # create the logo screen
   $form->header() unless $form->{noheader};
@@ -177,9 +174,8 @@ sub company_logo {
 
 sub show_error {
   my $template           = shift;
-  my %myconfig = %main::myconfig;
-  $locale                = Locale->new($main::language, 'all');
-  $myconfig{countrycode} = $main::language;
+  my %myconfig           = %main::myconfig;
+  $myconfig{countrycode} = $::lx_office_conf{system}->{language};
   $form->{stylesheet}    = 'css/lx-office-erp.css';
 
   $form->header();
@@ -188,7 +184,7 @@ sub show_error {
   # $form->parse_html_template('login/auth_db_unreachable');
   # $form->parse_html_template('login/authentication_pl_missing');
 
-  exit;
+  ::end_of_request();
 }
 
 1;