X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=bin%2Fmozilla%2Flogin.pl;h=92fa25db39d1f2333d0dcb742363bb47aa0fa34b;hb=c2d72edadd2639c4dd854a3ad4daf29ebd4c4f2b;hp=bd318fbcfaf4d1398f7f85cd8923429a2c421f45;hpb=d69fdcda39579b4807443f377a7624c8838ff4f2;p=kivitendo-erp.git diff --git a/bin/mozilla/login.pl b/bin/mozilla/login.pl index bd318fbcf..92fa25db3 100644 --- a/bin/mozilla/login.pl +++ b/bin/mozilla/login.pl @@ -28,100 +28,92 @@ ####################################################################### 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 "$form->{path}/custom_$form->{script}") { - eval { require "$form->{path}/custom_$form->{script}"; }; +if (-f "bin/mozilla/custom_$form->{script}") { + eval { require "bin/mozilla/custom_$form->{script}"; }; $form->error($@) if ($@); } # per login customization -if (-f "$form->{path}/$form->{login}_$form->{script}") { - eval { require "$form->{path}/$form->{login}_$form->{script}"; }; +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}"; +$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'; +} + +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(); -if ($form->{action}) { $form->{titlebar} .= " - $myconfig{name} - $myconfig{dbname}"; - &{ $locale->findsub($form->{action}) }; + call_sub($locale->findsub($action)); + } else { - &login_screen; + login_screen(); } 1; sub login_screen { $lxdebug->enter_sub(); + my ($msg) = @_; if (-f "css/lx-office-erp.css") { $form->{stylesheet} = "lx-office-erp.css"; } - $form->{fokus} = "loginscreen.login"; - $form->header; - - print qq| - - -
- -- -+ $form->{msg} = $msg; + $form->header(); -
![]() | - . $locale->text('Version') . qq| $form->{version} -- -- - - - |
-