1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 ######################################################################
8 # SQL-Ledger Accounting
9 # Copyright (c) 1998-2002
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #######################################################################
35 require "bin/mozilla/common.pl";
37 # This is required because the am.pl in the root directory
38 # is not scanned by locales.pl:
39 # $form->parse_html_template('login/password_error')
43 if (! -f 'config/authentication.pl') {
44 show_error('login/authentication_pl_missing');
47 $locale = new Locale $language, "login";
49 our $auth = SL::Auth->new();
50 if (!$auth->session_tables_present()) {
51 show_error('login/auth_db_unreachable');
53 $auth->expire_sessions();
54 $auth->restore_session();
57 if (-f "bin/mozilla/custom_$form->{script}") {
58 eval { require "bin/mozilla/custom_$form->{script}"; };
59 $form->error($@) if ($@);
62 # per login customization
63 if (-f "bin/mozilla/$form->{login}_$form->{script}") {
64 eval { require "bin/mozilla/$form->{login}_$form->{script}"; };
65 $form->error($@) if ($@);
68 # window title bar, user info
69 $form->{titlebar} = "Lx-Office " . $locale->text('Version') . " $form->{version}";
71 my $action = $form->{action};
73 if (!$action && $auth->{SESSION}->{login}) {
78 our %myconfig = $auth->read_user($form->{login}) if ($form->{login});
80 if (!$myconfig{login} || (SL::Auth::OK != $auth->authenticate($form->{login}, $form->{password}, 0))) {
81 $form->{error_message} = $locale->text('Incorrect Password!');
86 $auth->set_session_value('login', $form->{login}, 'password', $form->{password});
87 $auth->create_or_refresh_session();
89 $form->{titlebar} .= " - $myconfig{name} - $myconfig{dbname}";
90 call_sub($locale->findsub($action));
99 $lxdebug->enter_sub();
102 if (-f "css/lx-office-erp.css") {
103 $form->{stylesheet} = "lx-office-erp.css";
107 $form->{fokus} = "loginscreen.login";
110 print $form->parse_html_template('login/login_screen');
112 $lxdebug->leave_sub();
116 $lxdebug->enter_sub();
118 unless ($form->{login}) {
119 login_screen($locale->text('You did not enter a name!'));
123 $user = new User $form->{login};
125 # if we get an error back, bale out
126 if (($result = $user->login($form)) <= -1) {
127 exit if $result == -2;
128 login_screen($locale->text('Incorrect username or password!'));
132 my %style_to_script_map = ( 'v3' => 'v3',
137 my $menu_script = $style_to_script_map{$user->{menustyle}} || '';
139 # made it this far, execute the menu
140 $form->{callback} = build_std_url("script=menu${menu_script}.pl", 'action=display');
142 $auth->set_cookie_environment_variable();
146 $lxdebug->leave_sub();
150 $lxdebug->enter_sub();
152 $auth->destroy_session();
154 # remove the callback to display the message
155 $form->{callback} = "login.pl?action=";
156 $form->redirect($locale->text('You are logged out!'));
158 $lxdebug->leave_sub();
162 $lxdebug->enter_sub();
164 $locale = new Locale $myconfig{countrycode}, "login" if ($language ne $myconfig{countrycode});
166 $form->{stylesheet} = $myconfig{stylesheet};
167 $form->{title} = $locale->text('About');
169 # create the logo screen
170 $form->header() unless $form->{noheader};
172 print $form->parse_html_template('login/company_logo');
174 $lxdebug->leave_sub();
178 my $template = shift;
179 $locale = Locale->new($language, 'all');
180 $myconfig{countrycode} = $language;
181 $form->{stylesheet} = 'css/lx-office-erp.css';
184 print $form->parse_html_template($template);
186 # $form->parse_html_template('login/auth_db_unreachable');
187 # $form->parse_html_template('login/authentication_pl_missing');