X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Flogin.pl;h=49cb6c613e62bfafc0e48a6ee58457d13360ac96;hb=3a94f4d2dd9a835d4a7007e1b999ea00b3c4e1cd;hp=7488dd18cf5f69f2213fdaeda68a14eb22f5008d;hpb=33c1a7f111af21221572871e95a1b77e3e16aa51;p=kivitendo-erp.git diff --git a/bin/mozilla/login.pl b/bin/mozilla/login.pl index 7488dd18c..49cb6c613 100644 --- a/bin/mozilla/login.pl +++ b/bin/mozilla/login.pl @@ -35,75 +35,55 @@ use SL::Form; require "bin/mozilla/common.pl"; require "bin/mozilla/todo.pl"; -# This is required because the am.pl in the root directory -# is not scanned by locales.pl: -# $form->parse_html_template('login/password_error') +use strict; -$form = new Form; +our $cgi; +our $form; +our $auth; -if (! -f 'config/authentication.pl') { - show_error('login/authentication_pl_missing'); -} - -$locale = new Locale $language, "login"; - -our $auth = SL::Auth->new(); -if (!$auth->session_tables_present()) { - show_error('login/auth_db_unreachable'); -} -$auth->expire_sessions(); -my $session_result = $auth->restore_session(); +sub run { + $::lxdebug->enter_sub; + my $session_result = shift; -# customization -if (-f "bin/mozilla/custom_$form->{script}") { - eval { require "bin/mozilla/custom_$form->{script}"; }; - $form->error($@) if ($@); -} - -# per login customization -if (-f "bin/mozilla/$form->{login}_$form->{script}") { - eval { require "bin/mozilla/$form->{login}_$form->{script}"; }; - $form->error($@) if ($@); -} - -# window title bar, user info -$form->{titlebar} = "Lx-Office " . $locale->text('Version') . " $form->{version}"; - -if (SL::Auth::SESSION_EXPIRED == $session_result) { - $form->{error_message} = $locale->text('The session is invalid or has expired.'); - login_screen(); - exit; -} - -my $action = $form->{action}; - -if (!$action && $auth->{SESSION}->{login}) { - $action = 'login'; -} + $cgi = $::cgi; + $form = $::form; + $auth = $::auth; -if ($action) { - our %myconfig = $auth->read_user($form->{login}) if ($form->{login}); + $form->{stylesheet} = "lx-office-erp.css"; + $form->{favicon} = "favicon.ico"; - if (!$myconfig{login} || (SL::Auth::OK != $auth->authenticate($form->{login}, $form->{password}, 0))) { - $form->{error_message} = $locale->text('Incorrect Password!'); + if (SL::Auth::SESSION_EXPIRED == $session_result) { + $form->{error_message} = $::locale->text('The session is invalid or has expired.'); + login_screen(); + ::end_of_request(); + } + my $action = $form->{action}; + if (!$action && $auth->{SESSION}->{login}) { + $action = 'login'; + } + if ($action) { + %::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 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)); + } + } else { login_screen(); - exit; } - $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)); - -} else { - login_screen(); + $::lxdebug->leave_sub; } -1; - sub login_screen { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); my ($msg) = @_; if (-f "css/lx-office-erp.css") { @@ -115,77 +95,87 @@ sub login_screen { print $form->parse_html_template('login/login_screen'); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub login { - $lxdebug->enter_sub(); + $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(); } - $user = new User $form->{login}; + my $user = new User $form->{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', 'neu' => 'new', + 'v4' => 'v4', 'xml' => 'XML', ); my $menu_script = $style_to_script_map{$user->{menustyle}} || ''; # made it this far, execute the menu - $form->{callback} = build_std_url("script=menu${menu_script}.pl", 'action=display'); + # standard redirect does not seem to work for this invocation, (infinite loops?) + # do a manual invocation instead +# $form->{callback} = build_std_url("script=menu${menu_script}.pl", 'action=display', "callback=" . $form->escape($form->{callback})); + + $main::auth->set_cookie_environment_variable(); + + $::form->{script} = "menu${menu_script}.pl"; + $::form->{action} = 'display'; + $::form->{callback} = $::form->escape($::form->{callback}); - $auth->set_cookie_environment_variable(); + require "bin/mozilla/$::form->{script}"; + display(); - $form->redirect(); +# $form->redirect(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub logout { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); - $auth->destroy_session(); + $main::auth->destroy_session(); # 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!')); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub company_logo { - $lxdebug->enter_sub(); - - $locale = new Locale $myconfig{countrycode}, "login" if ($language ne $myconfig{countrycode}); + $main::lxdebug->enter_sub(); + my %myconfig = %main::myconfig; $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}; print $form->parse_html_template('login/company_logo'); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub show_error { my $template = shift; - $locale = Locale->new($language, 'all'); - $myconfig{countrycode} = $language; + my %myconfig = %main::myconfig; + $myconfig{countrycode} = $::lx_office_conf{system}->{language}; $form->{stylesheet} = 'css/lx-office-erp.css'; $form->header(); @@ -194,6 +184,9 @@ sub show_error { # $form->parse_html_template('login/auth_db_unreachable'); # $form->parse_html_template('login/authentication_pl_missing'); - exit; + ::end_of_request(); } +1; + +__END__