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";
36 require "bin/mozilla/todo.pl";
38 # This is required because the am.pl in the root directory
39 # is not scanned by locales.pl:
40 # $form->parse_html_template('login/password_error')
44 if (! -f 'config/authentication.pl') {
45 show_error('login/authentication_pl_missing');
48 $locale = new Locale $language, "login";
50 our $auth = SL::Auth->new();
51 if (!$auth->session_tables_present()) {
52 show_error('login/auth_db_unreachable');
54 $auth->expire_sessions();
55 $auth->restore_session();
58 if (-f "bin/mozilla/custom_$form->{script}") {
59 eval { require "bin/mozilla/custom_$form->{script}"; };
60 $form->error($@) if ($@);
63 # per login customization
64 if (-f "bin/mozilla/$form->{login}_$form->{script}") {
65 eval { require "bin/mozilla/$form->{login}_$form->{script}"; };
66 $form->error($@) if ($@);
69 # window title bar, user info
70 $form->{titlebar} = "Lx-Office " . $locale->text('Version') . " $form->{version}";
72 my $action = $form->{action};
74 if (!$action && $auth->{SESSION}->{login}) {
79 our %myconfig = $auth->read_user($form->{login}) if ($form->{login});
81 if (!$myconfig{login} || (SL::Auth::OK != $auth->authenticate($form->{login}, $form->{password}, 0))) {
82 $form->{error_message} = $locale->text('Incorrect Password!');
87 $auth->set_session_value('login', $form->{login}, 'password', $form->{password});
88 $auth->create_or_refresh_session();
90 $form->{titlebar} .= " - $myconfig{name} - $myconfig{dbname}";
91 call_sub($locale->findsub($action));
100 $lxdebug->enter_sub();
103 if (-f "css/lx-office-erp.css") {
104 $form->{stylesheet} = "lx-office-erp.css";
108 $form->{fokus} = "loginscreen.login";
111 print $form->parse_html_template('login/login_screen');
113 $lxdebug->leave_sub();
117 $lxdebug->enter_sub();
119 unless ($form->{login}) {
120 login_screen($locale->text('You did not enter a name!'));
124 $user = new User $form->{login};
126 # if we get an error back, bale out
127 if (($result = $user->login($form)) <= -1) {
128 exit if $result == -2;
129 login_screen($locale->text('Incorrect username or password!'));
133 my %style_to_script_map = ( 'v3' => 'v3',
138 my $menu_script = $style_to_script_map{$user->{menustyle}} || '';
140 # made it this far, execute the menu
141 $form->{callback} = build_std_url("script=menu${menu_script}.pl", 'action=display');
143 $auth->set_cookie_environment_variable();
147 $lxdebug->leave_sub();
151 $lxdebug->enter_sub();
153 $auth->destroy_session();
155 # remove the callback to display the message
156 $form->{callback} = "login.pl?action=";
157 $form->redirect($locale->text('You are logged out!'));
159 $lxdebug->leave_sub();
163 $lxdebug->enter_sub();
165 $locale = new Locale $myconfig{countrycode}, "login" if ($language ne $myconfig{countrycode});
167 $form->{todo_list} = create_todo_list('login_screen' => 1) if (!$form->{no_todo_list});
169 $form->{stylesheet} = $myconfig{stylesheet};
170 $form->{title} = $locale->text('About');
172 # create the logo screen
173 $form->header() unless $form->{noheader};
175 print $form->parse_html_template('login/company_logo');
177 $lxdebug->leave_sub();
181 my $template = shift;
182 $locale = Locale->new($language, 'all');
183 $myconfig{countrycode} = $language;
184 $form->{stylesheet} = 'css/lx-office-erp.css';
187 print $form->parse_html_template($template);
189 # $form->parse_html_template('login/auth_db_unreachable');
190 # $form->parse_html_template('login/authentication_pl_missing');