X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Flogin.pl;h=d52a69b496b4ddfa74da49b28fa992e8db284f10;hb=c69b3d4d4fef109ecc8627eb79481ed717ef76f2;hp=f09b8825835462c1d0e0639216ee57c999774fdf;hpb=40782548cf82ac1e4c0fe417113a4cb3072e9390;p=kivitendo-erp.git diff --git a/bin/mozilla/login.pl b/bin/mozilla/login.pl index f09b88258..d52a69b49 100644 --- a/bin/mozilla/login.pl +++ b/bin/mozilla/login.pl @@ -28,219 +28,173 @@ ####################################################################### use DBI; +use SL::Auth; use SL::User; use SL::Form; require "bin/mozilla/common.pl"; +require "bin/mozilla/todo.pl"; -$form = new Form; +use strict; -$locale = new Locale $language, "login"; +our $cgi; +our $form; +our $auth; -# customization -if (-f "$form->{path}/custom_$form->{script}") { - eval { require "$form->{path}/custom_$form->{script}"; }; - $form->error($@) if ($@); -} +sub run { + $::lxdebug->enter_sub; + my $session_result = shift; -# per login customization -if (-f "$form->{path}/$form->{login}_$form->{script}") { - eval { require "$form->{path}/$form->{login}_$form->{script}"; }; - $form->error($@) if ($@); -} + $form = $::form; + $auth = $::auth; -# window title bar, user info -$form->{titlebar} = - "Lx-Office " . $locale->text('Version') . " $form->{version}"; + $form->{stylesheet} = "lx-office-erp.css"; + $form->{favicon} = "favicon.ico"; -if ($form->{action}) { - $form->{titlebar} .= " - $myconfig{name} - $myconfig{dbname}"; - call_sub($locale->findsub($form->{action})); -} else { - &login_screen; -} + 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 (SL::Auth::OK != $auth->authenticate($::myconfig{login}, $form->{password})) { + $form->{error_message} = $::locale->text('Incorrect username or password!'); + login_screen(); + } else { + $auth->store_credentials_in_session(login => $form->{login}, password => $form->{password}); + $auth->create_or_refresh_session(); + delete $form->{password}; + + $form->{titlebar} .= " - $::myconfig{name} - $::myconfig{dbname}"; + call_sub($::locale->findsub($action)); + } + } else { + login_screen(); + } -1; + $::lxdebug->leave_sub; +} sub login_screen { - $lxdebug->enter_sub(); + $main::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(); + print $form->parse_html_template('login/login_screen'); -
+ $main::lxdebug->leave_sub(); +} -+sub login { + $main::lxdebug->enter_sub(); -+ unless ($form->{login}) { + login_screen($::locale->text('You did not enter a name!')); + ::end_of_request(); + } -