X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Flogin.pl;h=7488dd18cf5f69f2213fdaeda68a14eb22f5008d;hb=786b3862388eb8d4cdcc5dfc663a37fe0e9a82a1;hp=06e95fa14f1385582091966aa7780a112f3475ce;hpb=b0a92688aa0280c8614c8b173691045798a1767e;p=kivitendo-erp.git diff --git a/bin/mozilla/login.pl b/bin/mozilla/login.pl index 06e95fa14..7488dd18c 100644 --- a/bin/mozilla/login.pl +++ b/bin/mozilla/login.pl @@ -28,15 +28,32 @@ ####################################################################### use DBI; +use SL::Auth; use SL::User; 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') $form = new Form; +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(); + # customization if (-f "bin/mozilla/custom_$form->{script}") { eval { require "bin/mozilla/custom_$form->{script}"; }; @@ -52,9 +69,32 @@ if (-f "bin/mozilla/$form->{login}_$form->{script}") { # window title bar, user info $form->{titlebar} = "Lx-Office " . $locale->text('Version') . " $form->{version}"; -if ($form->{action}) { +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'; +} + +if ($action) { + our %myconfig = $auth->read_user($form->{login}) if ($form->{login}); + + if (!$myconfig{login} || (SL::Auth::OK != $auth->authenticate($form->{login}, $form->{password}, 0))) { + $form->{error_message} = $locale->text('Incorrect Password!'); + 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($form->{action})); + call_sub($locale->findsub($action)); } else { login_screen(); @@ -70,9 +110,8 @@ sub login_screen { $form->{stylesheet} = "lx-office-erp.css"; } - $form->{msg} = $msg; - $form->{fokus} = "loginscreen.login"; - $form->header; + $form->{msg} = $msg; + $form->header(); print $form->parse_html_template('login/login_screen'); @@ -87,10 +126,10 @@ sub login { exit; } - $user = new User $memberfile, $form->{login}; + $user = new User $form->{login}; # if we get an error back, bale out - if (($result = $user->login(\%$form, $userspath)) <= -1) { + if (($result = $user->login($form)) <= -1) { exit if $result == -2; login_screen($locale->text('Incorrect username or password!')); exit; @@ -106,6 +145,8 @@ sub login { # made it this far, execute the menu $form->{callback} = build_std_url("script=menu${menu_script}.pl", 'action=display'); + $auth->set_cookie_environment_variable(); + $form->redirect(); $lxdebug->leave_sub(); @@ -114,10 +155,10 @@ sub login { sub logout { $lxdebug->enter_sub(); - unlink "$userspath/$form->{login}.conf"; + $auth->destroy_session(); # remove the callback to display the message - $form->{callback} = "login.pl?action=&login="; + $form->{callback} = "login.pl?action="; $form->redirect($locale->text('You are logged out!')); $lxdebug->leave_sub(); @@ -126,10 +167,10 @@ sub logout { sub company_logo { $lxdebug->enter_sub(); - require "$userspath/$form->{login}.conf"; - $locale = new Locale $myconfig{countrycode}, "login" if ($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'); @@ -140,3 +181,19 @@ sub company_logo { $lxdebug->leave_sub(); } + +sub show_error { + my $template = shift; + $locale = Locale->new($language, 'all'); + $myconfig{countrycode} = $language; + $form->{stylesheet} = 'css/lx-office-erp.css'; + + $form->header(); + print $form->parse_html_template($template); + + # $form->parse_html_template('login/auth_db_unreachable'); + # $form->parse_html_template('login/authentication_pl_missing'); + + exit; +} +