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";
45 $::lxdebug->enter_sub;
46 my $session_result = shift;
51 $form->{stylesheet} = "lx-office-erp.css";
52 $form->{favicon} = "favicon.ico";
54 if (SL::Auth::SESSION_EXPIRED == $session_result) {
55 $form->{error_message} = $::locale->text('The session is invalid or has expired.');
59 my $action = $form->{action};
60 if (!$action && $auth->{SESSION}->{login}) {
64 %::myconfig = $auth->read_user($form->{login}) if ($form->{login});
65 $::locale = Locale->new($::myconfig{countrycode}) if $::myconfig{countrycode};
67 if (SL::Auth::OK != $auth->authenticate($::myconfig{login}, $form->{password})) {
68 $form->{error_message} = $::locale->text('Incorrect username or password!');
71 $auth->store_credentials_in_session(login => $form->{login}, password => $form->{password});
72 $auth->create_or_refresh_session();
73 delete $form->{password};
75 $form->{titlebar} .= " - $::myconfig{name} - $::myconfig{dbname}";
76 call_sub($::locale->findsub($action));
82 $::lxdebug->leave_sub;
86 $main::lxdebug->enter_sub();
89 if (-f "css/lx-office-erp.css") {
90 $form->{stylesheet} = "lx-office-erp.css";
96 print $form->parse_html_template('login/login_screen');
98 $main::lxdebug->leave_sub();
102 $main::lxdebug->enter_sub();
104 unless ($form->{login}) {
105 login_screen($::locale->text('You did not enter a name!'));
109 my $user = new User $form->{login};
111 # if we get an error back, bale out
113 if (($result = $user->login($form)) <= -1) {
115 show_error('login/auth_db_needs_update');
116 $::auth->destroy_session;
120 ::end_of_request() if $result == -2;
121 login_screen($::locale->text('Incorrect username or password!'));
125 my %style_to_script_map = (
131 my $menu_script = $style_to_script_map{$user->{menustyle}} || '';
133 # made it this far, execute the menu
134 # standard redirect does not seem to work for this invocation, (infinite loops?)
135 # do a manual invocation instead
136 # $form->{callback} = build_std_url("script=menu${menu_script}.pl", 'action=display', "callback=" . $form->escape($form->{callback}));
138 $main::auth->set_cookie_environment_variable();
140 $::form->{script} = "menu${menu_script}.pl";
141 $::form->{action} = 'display';
142 $::form->{callback} = $::form->escape($::form->{callback});
144 require "bin/mozilla/$::form->{script}";
149 $main::lxdebug->leave_sub();
153 $main::lxdebug->enter_sub();
155 $main::auth->destroy_session();
157 # remove the callback to display the message
158 $form->{callback} = "login.pl?action=";
159 $form->redirect($::locale->text('You are logged out!'));
161 $main::lxdebug->leave_sub();
165 $main::lxdebug->enter_sub();
167 my %myconfig = %main::myconfig;
168 $form->{todo_list} = create_todo_list('login_screen' => 1) if (!$form->{no_todo_list});
170 $form->{stylesheet} = $myconfig{stylesheet};
171 $form->{title} = $::locale->text('Lx-Office');
172 $form->{interface} = $::dispatcher->interface_type;
174 # create the logo screen
175 $form->header() unless $form->{noheader};
177 print $form->parse_html_template('login/company_logo');
179 $main::lxdebug->leave_sub();
183 my $template = shift;
184 my %myconfig = %main::myconfig;
185 $myconfig{countrycode} = $::lx_office_conf{system}->{language};
186 $form->{stylesheet} = 'css/lx-office-erp.css';
189 print $form->parse_html_template($template);
191 # $form->parse_html_template('login/auth_db_unreachable');
192 # $form->parse_html_template('login/auth_db_needs_update');
193 # $form->parse_html_template('login/authentication_pl_missing');