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 if ($form->{action}) {
72 our %myconfig = $auth->read_user($form->{login}) if ($form->{login});
74 if (!$myconfig{login} || (SL::Auth::OK != $auth->authenticate($form->{login}, $form->{password}, 0))) {
75 $form->{error_message} = $locale->text('Incorrect Password!');
80 $auth->set_session_value('login', $form->{login}, 'password', $form->{password});
81 $auth->create_or_refresh_session();
83 $form->{titlebar} .= " - $myconfig{name} - $myconfig{dbname}";
84 call_sub($locale->findsub($form->{action}));
93 $lxdebug->enter_sub();
96 if (-f "css/lx-office-erp.css") {
97 $form->{stylesheet} = "lx-office-erp.css";
101 $form->{fokus} = "loginscreen.login";
104 print $form->parse_html_template('login/login_screen');
106 $lxdebug->leave_sub();
110 $lxdebug->enter_sub();
112 unless ($form->{login}) {
113 login_screen($locale->text('You did not enter a name!'));
117 $user = new User $form->{login};
119 # if we get an error back, bale out
120 if (($result = $user->login($form)) <= -1) {
121 exit if $result == -2;
122 login_screen($locale->text('Incorrect username or password!'));
126 my %style_to_script_map = ( 'v3' => 'v3',
131 my $menu_script = $style_to_script_map{$user->{menustyle}} || '';
133 # made it this far, execute the menu
134 $form->{callback} = build_std_url("script=menu${menu_script}.pl", 'action=display');
136 $auth->set_cookie_environment_variable();
140 $lxdebug->leave_sub();
144 $lxdebug->enter_sub();
146 $auth->destroy_session();
148 # remove the callback to display the message
149 $form->{callback} = "login.pl?action=";
150 $form->redirect($locale->text('You are logged out!'));
152 $lxdebug->leave_sub();
156 $lxdebug->enter_sub();
158 $locale = new Locale $myconfig{countrycode}, "login" if ($language ne $myconfig{countrycode});
160 $form->{stylesheet} = $myconfig{stylesheet};
161 $form->{title} = $locale->text('About');
163 # create the logo screen
164 $form->header() unless $form->{noheader};
166 print $form->parse_html_template('login/company_logo');
168 $lxdebug->leave_sub();
172 my $template = shift;
173 $locale = Locale->new($language, 'all');
174 $myconfig{countrycode} = $language;
175 $form->{stylesheet} = 'css/lx-office-erp.css';
178 print $form->parse_html_template($template);
180 # $form->parse_html_template('login/auth_db_unreachable');
181 # $form->parse_html_template('login/authentication_pl_missing');