X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Flogin.pl;h=7488dd18cf5f69f2213fdaeda68a14eb22f5008d;hb=787248feb4b2ea860d35574f35c2c020070bd407;hp=e88872113808af90cbf6a61d87065bbbb69b9ad2;hpb=de763d70b4b2e0501565e579fb4726e033594589;p=kivitendo-erp.git diff --git a/bin/mozilla/login.pl b/bin/mozilla/login.pl index e88872113..7488dd18c 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| - - -
- -- -- -
-| - . $locale->text('Version') . qq| $form->{version} -+ $form->{msg} = $msg; + $form->header(); -- - - - |
-