X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Flogin.pl;h=49cb6c613e62bfafc0e48a6ee58457d13360ac96;hb=3a94f4d2dd9a835d4a7007e1b999ea00b3c4e1cd;hp=39890982d56b9c5501814ab7e1a48b8cb6f6b778;hpb=d629acd82a27e980899a044ca8b0f4becc8e94bb;p=kivitendo-erp.git diff --git a/bin/mozilla/login.pl b/bin/mozilla/login.pl index 39890982d..49cb6c613 100644 --- a/bin/mozilla/login.pl +++ b/bin/mozilla/login.pl @@ -28,218 +28,165 @@ ####################################################################### 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 "bin/mozilla/custom_$form->{script}") { - eval { require "bin/mozilla/custom_$form->{script}"; }; - $form->error($@) if ($@); -} +sub run { + $::lxdebug->enter_sub; + my $session_result = shift; -# per login customization -if (-f "bin/mozilla/$form->{login}_$form->{script}") { - eval { require "bin/mozilla/$form->{login}_$form->{script}"; }; - $form->error($@) if ($@); -} + $cgi = $::cgi; + $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 (!$::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(); + } -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(); -
- - - - -
+ require "bin/mozilla/$::form->{script}"; + display(); - - -|; +# $form->redirect(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } -sub login { - $lxdebug->enter_sub(); - - $form->error($locale->text('You did not enter a name!')) - unless ($form->{login}); - - $user = new User $memberfile, $form->{login}; +sub logout { + $main::lxdebug->enter_sub(); - # if we get an error back, bale out - if (($errno = $user->login(\%$form, $userspath)) <= -1) { - $errno *= -1; - $err[1] = $err[3] = $locale->text('Incorrect username or password!'); + $main::auth->destroy_session(); - if ($errno == 2) { - exit; - } - - $form->error($err[$errno]); - } + # remove the callback to display the message + $form->{callback} = "login.pl?action="; + $form->redirect($::locale->text('You are logged out!')); - # made it this far, execute the menu - if ($user->{menustyle} eq "v3") { - $form->{callback} = - "menuv3.pl?login=$form->{login}&password=$form->{password}&action=display"; - } elsif ($user->{menustyle} eq "neu") { - $form->{callback} = - "menunew.pl?login=$form->{login}&password=$form->{password}&action=display"; - } else { - $form->{callback} = - "menu.pl?login=$form->{login}&password=$form->{password}&action=display"; - } + $main::lxdebug->leave_sub(); +} - $form->redirect; +sub company_logo { + $main::lxdebug->enter_sub(); - $lxdebug->leave_sub(); -} + my %myconfig = %main::myconfig; + $form->{todo_list} = create_todo_list('login_screen' => 1) if (!$form->{no_todo_list}); -sub logout { - $lxdebug->enter_sub(); + $form->{stylesheet} = $myconfig{stylesheet}; + $form->{title} = $::locale->text('Lx-Office'); - unlink "$userspath/$form->{login}.conf"; + # create the logo screen + $form->header() unless $form->{noheader}; - # remove the callback to display the message - $form->{callback} = "login.pl?action=&login="; - $form->redirect($locale->text('You are logged out!')); + print $form->parse_html_template('login/company_logo'); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } -sub company_logo { - $lxdebug->enter_sub(); +sub show_error { + my $template = shift; + my %myconfig = %main::myconfig; + $myconfig{countrycode} = $::lx_office_conf{system}->{language}; + $form->{stylesheet} = 'css/lx-office-erp.css'; - require "$userspath/$form->{login}.conf"; - $locale = new Locale $myconfig{countrycode}, "login" - unless ($language eq $myconfig{countrycode}); + $form->header(); + print $form->parse_html_template($template); - $myconfig{address} =~ s/\\n/
/g; - $myconfig{dbhost} = $locale->text('localhost') unless $myconfig{dbhost}; + # $form->parse_html_template('login/auth_db_unreachable'); + # $form->parse_html_template('login/authentication_pl_missing'); - map { $form->{$_} = $myconfig{$_} } qw(charset stylesheet); + ::end_of_request(); +} - $form->{title} = $locale->text('About'); +1; - # create the logo screen - $form->header unless $form->{noheader}; - - print qq| - -
- - - -| . $locale->text('Licensed to') . qq| -

- -$myconfig{company} -
$myconfig{address} -
- - -
- - - - - - - - - - - - - - - - - - - - - - - -
| . $locale->text('User') . qq|$myconfig{name}
| . $locale->text('Dataset') . qq|$myconfig{dbname}
| . $locale->text('Database Host') . qq|$myconfig{dbhost}
http://lx-office.org
info@lx-office.org
- -

- - - -|; - - $lxdebug->leave_sub(); -} +__END__